Hello, new here and hoped someone could assist me.
The description for the task was:
returns 1 if a word is successfully read & stored in the array word of n characters; otherwise returns 0 on end of file or when the user inputs the word eof
I think I am close but it doesn't quite work so I was hoping someone could point out what's going wrong, because I am not seeing it!
The problems I am having are:
- when I try to enter the eof (byebyenow in this case) the program tells me it is too long, and doesn't exit.
- a word with <= 4 characters will cause a "STATUS_ACCESS_VIOLATION" error and it creates a stackdumpfile
- 5 or 6 characters is also apparently too long
Thanks for helping!
#define BUFSIZE 32
int get_word(const char prompt, char word, size_t n, const char eof);
int get_word(const char prompt, char word, size_t n, const char eof)
if(fgets(line, BUFSIZE, stdin) != NULL)
if(strcmp(line, eof) == 0)
if(strlen(line) < n)
printf("%s was 6 or less chars. Thankyou\n", line);
printf("%s was too long! Try again.\n", line);
if(get_word("Enter a word with 6 chars or less, or BYEBYENOW to quit.", input, 6, "BYEBYENOW") == 1)