I want to input strings to an array in C, the code I have is this:
int main()
{
int sizeA;
printf("Tamanio de arreglo\n");
scanf("%i", &sizeA);
char names[sizeA];
for(int i = 0; i < sizeA; i++){
printf("Nombre %c\n", i+1 );
scanf("%c", &names[i]);
}
printf("valores arreglo\n");
for(int i = 0; i < sizeA; i++){
printf("%c", names[i]);
}
return 0;
}
First of all I ask the size of the array, in case of entering 5
as the length of the array, when I enter the value of the strings at the time of requesting the Nombre
name, I get the name request twice, which in the end allows me to enter 2
the string only times and not the 5
ones you enter as length. How can I enter the 5 values? Thanks in advance. When I do it with integers it lets me enter the 5 values correctly and with strings it doesn't.