Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > sorry! i had changed it to c

Reply
Thread Tools

sorry! i had changed it to c

 
 
Guest
Posts: n/a
 
      03-22-2005

<> 写入消息新闻:...
> sorry! i am not prepense
> i write it in c , and comp it under win2k and freebsd5.3
>
> in freebsd
> p [ 294 ] ok
> 1048576
> Killed
>
>
> ///////////////////////////////////////////
> #include <stdio.h>
> #include <stdlib.h>
> const int len = 2000;
> int main()
> {
> char* p1[len];
> int i =0;
> int x =0;
> static int size = 1<<20;
> printf( "%d \n", size);
> for ( i =0 ; i < len ;i++)
> {
> p1[i] = (char*) malloc (size);
> printf( "%d \n", size );
> char *tp = p1[i];
> for ( x =0 ; x< (size-1); x++)
> {
> //cout << x << endl;
> *(tp+x) = (char)( (x%26)+ 4;
>
> }
> *(tp+size-1) =0;
> printf( "p [ %d ] ok\n" , i);
> }
>
> for ( i =0 ; i < len ;i++)
> {
> free(p1[i]);
> }
> return 0;
> }
>
>
>
> //////////////////////////////////////////
>
> "Martin Ambuhl" <>
> ??????:u6Q%d.965$ k.net...
> > wrote:
> > > hi
> > > i try to malloc 2G size mem . so i wirte code like that.

> >
> > You have no guarantee that you can do so. You need to check in a
> > newsgroup, mailing list, or tech support for your implementation.
> >
> > > it failt in freebsd 5.3 and win2k
> > > what's bug in my code ? how can i change it ?

> >
> > We really can't help, partially because you posted to comp.lang.c, where
> > we use C, and your code is not C. comp.lang.c++ is a different newsgroup
> > for a different language.
> >
> > Examples of C++isms are:
> > > #include <iostream>

> > This is not a C header.
> > > using namespace std;

> > This is a compilation error.
> > > #include <cstdlib>

> > This is not a C header.
> > > cout << size << endl;

> > 'cout' and 'endl' are undeclared identifiers, and '<<' is a
> > left-shift operator that probably don't do what you want.
> > > p1[i] = new char [size];

> > 'new' is an undeclared identifier, and the above is a compilation

> error.
> >
> > There are more instances, but I don't care to be tiresome.

>
>



 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      03-23-2005
On Tue, 22 Mar 2005 17:51:40 +0800, <> wrote
in comp.lang.c:

>
> <> 写入消息新闻:...
> > sorry! i am not prepense
> > i write it in c , and comp it under win2k and freebsd5.3
> >
> > in freebsd
> > p [ 294 ] ok
> > 1048576
> > Killed


The point is that no matter what language you write it in, the
limitations on how much memory your program can have are determined by
the system, not by the C language, or any other language.

If you want to know whether it is possible to allocate more memory
under Windows, ask in a Windows group like
news:comp.os.ms-windows.programmer.win32. For the same information
about Free BSD, ask in a BSD group or mailing list.

This is not a limitation of the C language, so the language can't tell
you how to overcome it, if indeed you can at all. Maybe you can't.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changed state to up changed state to down FastEthernet LINEPROTO-5-UPDOWN surrealarmada@gmail.com Cisco 3 03-07-2007 06:06 PM
scroll position is changed when style is changed? mxbrunet Javascript 1 11-03-2006 03:40 AM
Have you ever had your computer crashed at 3am and wished that you had someone to call? lifestylelink Computer Support 10 08-12-2006 03:05 PM
I had surgery, it's XhArD's fault... The Modfather The Lounge 59 10-16-2005 05:49 AM
xmlDocument.Save "&#10;" getting changed changed to "&amp;#10" st@jpa.co.jp ASP .Net 1 10-11-2005 01:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57