- #1
dwx1
- 6
- 0
I have to read a list of strings in from stdin and store them, stopping when a blank line is entered. Here's what I tried...
No luck. Does anyone know how to do it?
Thanks.
Code:
const int LINE_CAP = 100;
const int MAX_LENGTH = 80;
char *strings[LINE_CAP];
int strings_index = 0;
char buffer[MAX_LENGTH];
printf("%s", "Enter words:\n");
scanf("%s", buffer);
while(buffer != "")
{
strings[strings_index] = buffer;
strings_index++;
scanf("%s", buffer);
}
No luck. Does anyone know how to do it?
Thanks.