B
bpascal123
Hi,
I'd like to know if it would be possible to store constant string in
an array. I'd first like to avoid pointers so i can see how far we go
without pointers.
Example :
-o-
char str[8] ;
char str[0] = "ab" ;
char str[1] = "cd" ;
....
char str[7] = "op" ;
-o-
2° Would using a structure be more suitable?
3° What about a 2 dimensional array (even if it's a pain in c, with a
good algorithm behind, it should go through)...
4° And at last, if pointers were unvoidable would it be like this ?
-o-
char str[8] ;
char *pstr = str ;
pstr[0] = "ab";
pstr[1] = "cd" ;
-o-
I get for the last part : warning: assignment makes integer from
pointer without a cast
I know it should be 'a' and 'b' but i really need "ab", "cd" ...
I'd like to know if it would be possible to store constant string in
an array. I'd first like to avoid pointers so i can see how far we go
without pointers.
Example :
-o-
char str[8] ;
char str[0] = "ab" ;
char str[1] = "cd" ;
....
char str[7] = "op" ;
-o-
2° Would using a structure be more suitable?
3° What about a 2 dimensional array (even if it's a pain in c, with a
good algorithm behind, it should go through)...
4° And at last, if pointers were unvoidable would it be like this ?
-o-
char str[8] ;
char *pstr = str ;
pstr[0] = "ab";
pstr[1] = "cd" ;
-o-
I get for the last part : warning: assignment makes integer from
pointer without a cast
I know it should be 'a' and 'b' but i really need "ab", "cd" ...