this line gives me error , overflow in implicit constant conversion.Code:*array[0][0]='ass';
does that mean this line is wrong? or my malloc'ing is wrong?
this line gives me error , overflow in implicit constant conversion.Code:*array[0][0]='ass';
does that mean this line is wrong? or my malloc'ing is wrong?
How did you declare the array, and what are you actually trying to do?
Also 'ass' is a integer value (that is perhaps 0x617373, but that depends on the implementation of the compiler). It is very rarely a useful way to store characters.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
thnkx for quick response
Code:char ***array = (char ***)malloc(26 * sizeof(char **)); // mallocing one dimension for each alphabetical letter. for(i = 0; i <26; i++) { array[i] = (char **)malloc(wrdcnt * sizeof(char *)); // mallocing how many words will be contained in each letter dimension for(j=0; j<wrdcnt; j++) array[i][j] = (char *)malloc(35 * sizeof(int)); //mallocing the max size of each word, 3 letters max/per word }
I trying to make a 3d char array where it holds words alphabetically.
Last edited by ktran03; 02-01-2009 at 05:44 PM.
So to move strings around you need strcpy, not =.
Ok, and you are then trying to set one element to an integer value of 'ass', right? And you are suprised that the compiler says "implicit conversion from integer to pointer"?
If you mean to assign a string, then you should do one of the following (or something similar):
1. Use strcpy() to place it in the allocated 80-character string.
2. Not allocate the third level, and assign the string constants directly (not that then you should have const char ***array).
3. Not allocate the third level until you know what string you are storing, then allocate strlen(str)+1 bytes and use strcpy() to copy the content of the original string into the array.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
See, the error in your original thing was that *array[0][0] is a character variable, and 'ass' is most assuredly not a character. You need to strcpy (into array[i][j], not *array[i][j], 'cause as mentioned *array[i][j] is a character, not a pointer to a bunch of characters).
just tried
array[0][0] = 'ass';
I'm getting assignment makes pointer from integer without a cast.
what does that mean?
You do realize that 'ass' is illegal, right? If you wanted a string, you would use "ass".
In this case, you must not assign anything to array[0][0], as you will immediately leak your malloc'ed memory (it's gone, and you can't get it back). If you want to move strings around, you must use strcpy.