Re: [Dev-C++] One other minor problem
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Khalid El-K. <kha...@ho...> - 2003-04-13 03:18:45
|
>I also have one other minor problem. > >Though I have looked through over 16 different manuals and tutorials, and >have searched over 50 websites I cannot seem to find out the difference >between > >char* foo; >char *foo; >char* *foo; > >From my own expirements (purposely generating compiler errors) it >appears >to me that the first two are identical. They both seem to >declare foo to >be a variable of type char*. The second seems to >declare foo a pointer to >type char*. It also appears to me that type >char* is actually a char[] of >dynamic length because I can get string >functions to work on it - just >like on char[]. > >I have found no confirmation of any of this though. I would appreciate > >any info anyone has about this. Your thoughts are right, but the thing that produces compilation error, maybe the malloc/realloc/calloc thing associated with them: //for char**: char **str_arr; int num_of_elements = 5; str_arr = (char**) malloc(num_of_elements*sizeof(char*)); //the for each element of that array you should malloc str_arr[0] = (char*) malloc(10*sizeof(char); ... Hope that helps. >Shane Plesner Regards, Khalid Al-Kary _________________________________________________________________ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail |