The output from char array?

In the first cycle for processing the entered words.
In the second for loop to display rows that were received in 1 for loop

How do I output the words in the second cycle?
For example, if you add printf("%s", word), that word will be displayed.
But if in the same cycle to assign count[i] = word (where i is the iteration), and then in the second cycle to get it (printf("%s", count[i]), list only the most recent value of all i-times. I can not understand in what a problem, prompt please

#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>

int main() {

 char word1[32];
 int i = 0, t = 0;
 char *text[10000];

 for(t = 0; t < 5; t++){

 scanf_s("%s", word1, 32);

 // Carry out some operations with the string //


 text[t] = word1; // Try to save it in an array
}

 for (t = 0; t < N; t++) {
 printf("\n %d. %s \n", t. text[t]); // Trying to get
}


_getch();

}</stddef.h></string.h></stdlib.h></stdio.h></conio.h>
June 10th 19 at 14:19
1 answer
June 10th 19 at 14:21
text[t] = word1; // Try to save it in an array
to display only the most recent value of all i-times. I can not understand in what a problem, prompt please

So it's not the assignment line stores a pointer to the same buffer, word1, which is overwritten with the new string in each iteration of the first cycle. If you want to keep the line -- need to copy. For example:
for(t = 0; t < 5; t++){

 scanf_s("%s", word1, 32);

 // Carry out some operations with the string //


 text[t] = strdup(word1); // Trying to save it to the array previously trying to copy
}

 for (t = 0; t < N; t++) {
 printf("\n %d. %s \n", t. text[t]); // Trying to get
 free(text[t]); // Trying to free
 }

Find more questions by tags C