In this case, add a semicolon behind while() and it will repeat until the condition is false.
If it's not a loop, execute the statement once.
same concept as
while(getchar() != '\n');
which...
Type: Posts; User: xeon321
In this case, add a semicolon behind while() and it will repeat until the condition is false.
If it's not a loop, execute the statement once.
same concept as
while(getchar() != '\n');
which...
Line 82, ' ; '
remove it :D
C Programming
You sure bro?
line 47
while(option == 1) {
line 170
} //bracket do while
There you go
But Andi, that doesn't really work when you enter something like 1a, 1- or 2abcd.. ( basically any numbers followed by a character or string)
And when user input ' - ', it goes straight into...
(2) Add this into your else statement
while ((ch = getchar()) != '\n')
{
if(ch > 1)
{
printf("Error! Re-enter : ");
scanf("%d", &stop);
scanf leaves a newline char behind. So if you don't have 2 getchar(), the newline will be grabbed by getchar(), and your program automatically quits.
oh lol , I see now. Thanks!
Well, my question is, why do we need ( ch != EOF) ?
while(( ch = getchar()) != '\n' ); //understand
//don't understand the need of having != EOF
while ((ch = getchar()) != '\n' && ch !=...
Hmm, alright then. I will run through the books + the tutorials again and rewrite everything. Thanks for the help , appreciate it :)
Yeah, I was trying to simplify it because it's gonna be lengthy, but oh well...there you go.
And sometimes, it displays
"Unhandled exception at 0x530a3330 in PCD2Assignment.exe: 0xC0000005:...
So, I'm suppose to copy the ID that user input into another variable. But somehow, it gives me some problem/error.
For first attempt, no error shown. But, the spacing was off.
It would be like
...
tidy up your codes please D:
Hmm...Sad...Thanks for the help anyway. I guess I will just increase the size limit.
I want to increase my array's size, which is declared as 3, to a size of 5.
example :
int test[3];
I want to increase the array test size to 5
test[5];
How do I add an expression(modulus) according to how many digits user's input have?
Example :
If,
User input : 5832 ( 4 Digit )
4 digit = 4 modulus expressions
Ah...got what you mean there...........Thanks mate . . .
Uhh..............
Well...It prints Y/N:Y/N: _ without that line...
with that line , it prints Y/N: _
x.x
Guess I should go and get some sleep and figure it out when my brain's clear enough...
Haha, still have hard time understanding what is laserlight's concept in this line of code...So blur nooooooooow
while
((c = getchar()) != '\n') /* intentionally empty */;
#include...
Hmm, it is not required but still, I will stick to int, to prevent any nasty problems in the future :D
Thanks for this! Will change it from now on.
Yeah, I tested it with a string of random characters. It will still proceed like the input's all correct.
What I mean by "difference" is, why his is working while mine not. I don't know the reason...
Umm sorry , but I still don't quite understand what this line "while ((c = getchar()) != '\n')" does...
All I know is, while the user input is not enter..
YES! Yours exactly solved what I want!
Finally! If a user entered ridiculous answers, he's gonna get a slap from me! But still , besides that I used while loop to check the condition while you used...