do-while loop not working as expected
hello everyone,
on my path to better learning C, I wanted to make a do-while loop that asked the user to input. Code:
int main(void) What am i missing? Could anyone be so kind to point me to the right direction? Thanks in advance |
Quote:
You define a String, then you compare the *String* to some *content* (this does not make sense in C-like languages). What you want is compare the *content* of the String to another supposed *content*. There are functions in C and C++ for this very task. You have to use them instead of your above construct with "!=". Other languages handle this differently. If you have experience with other programming-universes, do as if you had never heard about them. |
Could i solve this by scan_f the user's name as a "userInput" sting? And then compare it to zzz while expression?
Or, maybe even simplier, just declare a string instead of a char? |
Go back and look at your playgame function in your puzzle program.
|
Quote:
|
Quote:
Anyway, pretty late here so i will have a lokk tmrw, or maybe nxt wkend )) Thank you |
Quote:
What would that function be. |
The code that checks the input for the coordinates can be modified to fit your do while loop.
|
Quote:
I was following this example Code:
#include <stdio.h> |
Quote:
found it! thank you! [got up at 5am this morning to get this out of my head :D] |
Programming is frustrating! I still can't get this to work.
when i input zzz the loop won't stop what else am i missing? Code:
#include <stdio.h> |
would be nice to read the documentation (man fgets):
Quote:
|
Quote:
Does it mean that I have to reduce the size of the char buffer? |
Gotcha!
I should use 'scanf' instead of 'fgets' I can start my normal day now. Thank you very much indeed everyone. |
That means not only zzz is stored, but the newline entered too. That's why the result was not equal to zzz ( but zzz\n )
Quote:
|
All times are GMT -5. The time now is 06:53 AM. |