|
-
Saving to a file and checking a string for a letter (in C)
I was wondering how I would go about checking the first letter entered into a string variable could be checked.
As can be seen in this block of code
fflush(stdin);
printf("\n\nEnter statement #d", ctr);
gets(statement);
while ((statement != "Q") | | (statement != "q"));
{
fputs(statement, fp);
ctr+=1;
fflush(stdin);
printf("\n\nEnter statement #%d",ctr);
printf("\n(Enter only Q or q to exit)\n");
gets(statement);
}
I am able to enter a text string, but am unable to compare it with the letters "Q" or "q".
I'm also having a problem with writing to the text file which is indicated by the pointer fp. What is it I may be doing wrong?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|