When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
18 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
you can't compare strings with == and !=
if you #include<string.h>, you can use a function called strcmp which takes two character pointers and returns
-1 if the first is lexicographical less than the second
0 if they are the same
1 if the first is lexicographical greater than the second
so what should i write exactly@burnt sedge
//...
#include <string.h>
//...
if (strcmp(p_name, "NO") == 0)
//...
you may need to compare with "NO\n", I forget if scanning %s include the newline or not
@burnt sedge it did the oppsite.i was when i enter NO the program stop
oh oops, != 0 instead of == 0
THANKS
@viscid flume Has your question been resolved? If so, run !solved :)
how do i keep prompting the user until the correct entry is made?
something like this
int age;
do {
prompt_user;
user_input();
} while (valid_age);
so i should take out the if statement?
your call, all I'm saying is that using a while loop to re-ask for input until a valid input is given is the most common way to do that
where should i put the do while in my program?
@burnt sedge
@viscid flume
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. You can use !solved to close a post and mark it as solved.
!solved