I'm very new to programming in C and I'm trying to print an array of strings. I can enter the input easily enough but then when it tries to print the array the program stops responding. Any help is appreciated, thanks.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main()
{
int a, b;
char answer[256];
for(a=1; a<=20; a++)
{
scanf("%s", &answer[a]);
}
for(b=1; b<=20; b++)
{
printf("%s\n", answer[b]);
}
}
Update: Thanks for all the fast replies everyone, the program is running smoothly now!