Hi,
I was hoping someone may be able to help me out.
I am trying to write a program which reads and prints an input of words.
It needs to hold a max of 10 words but i need use a sentinel contolled loop using the EOF (<ctrlZ> twice) so i can end it early if needed.
I have tried to use a while loop in scanf unsucessfully in the code below.
Any help would be greatly appreciated.
Cheers,
Mike.
Code:
#include <stdio.h>
#include <string.h>
main()
{
char word[10][100];
int a, x=0;
for(a=0; a<10; a++)
{
printf("enter a word\n");
scanf("%s", word[x]);
x=x+1;
}
x=0;
printf("the word list is:\n");
for(a=0; a<10; a++)
{
printf("%s\n", word[x]);
x=x+1;
}
}