#define NUM_STRINGS 10 #define STR_LEN 10 int main (void) { char words[NUM_STRINGS][STR_LEN]; char input[STR_LEN]; char *words_ptr[NUM_STRINGS]; char *temp; int i, j; int count = 0; for (i = 0; i < NUM_STRINGS; ++i) { printf("Enter a word (or 0 to quit): "); scanf ("%9s", input); discard_input(); if (input[0] == '0') break; strncpy(words[i], input, STR_LEN); words_ptr[i] = &words[i]; //mistake ++count; }
words_ptr[i] = (char*)&words[i]
words
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)