Mi sto insegnando C da un libro e sto cercando di creare un cruciverba. Devo creare una serie di stringhe ma continuare a incorrere in problemi. Inoltre, io non ne so molto di gamma ...Come creare un array di stringhe in C?
Questo è il pezzo di codice:
char word1 [6] ="fluffy", word2[5]="small",word3[5]="bunny";
char words_array[3]; /*This is my array*/
char *first_slot = &words_array[0]; /*I've made a pointer to the first slot of words*/
words_array[0]=word1; /*(line 20)Trying to put the word 'fluffy' into the fist slot of the array*/
Ma io continuo a ricevere il messaggio:
crossword.c:20:16: warning: assignment makes integer from pointer without a cast [enabled by default]
Non so cosa sia il problema ... Ho provato a cercare come creare una serie di stringhe ma senza fortuna
Qualsiasi aiuto sarà molto apprezzato,
Sam
prova a studiare un po 'di più sugli array http://pw1.netcom.com/~tjensen/ptr/pointers.htm. –
A proposito - 'char word1 [6] =" fluffy "' - "fluffy" è in realtà 7 caratteri. In C, una stringa termina con un '\ 0' - che occupa un carattere in più. – ArjunShankar
'const char * arr [] = {" literal "," string "," pointer "," array "};', e nota il ** const **. – WhozCraig