View Single Post
  #20   Spotlight this post!  
Unread 01-07-2007, 22:28
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: C Programming Homework Help Needed

Quote:
Originally Posted by Pat McCarthy View Post
That made that error go away but I still don't really understand how to use the function.
The first line:

char * buffer = new char[10];

is confusing me.
The use of the "new" operator is C++ speak, not C speak.

char buffer[10]; /* bigger than 10 is a good idea */

If a static or automatic array (depending on the location
of the declaration) is good enough, or

char *buffer;

buffer = malloc(10); /* again, bigger than 10 is a good idea */

to allocate the storage using the heap allocator in C.

Eugene