while(1)

Pages: 12
Wait, wait, wait. Why are you guys arguing amongst yourselves about what cppbeg said? It's not your fault he/she refuses to describe his/her problems in enough detail. Ask him/her to be more detailed and to explain better.
yes bluecoder , for example "a" will be "A" ..."c" "C"

ch is load with user input ,like i ask for 1 of the option in some function that her possiblities are only " A,D,C,X" when the user press B he will get "wrong key" when he press A it will enter the case.
hope i was understood.

1
2
3
4
5
char upcase ()             
{
	char ch = getch ();
	return toupper (ch);
}


Last edited on
@ccpbeg
does our replies answered all your questions?

What you're asking is about while(1) right?

Basically it is an infinite loop.

But why 1? it can be 2 or another number right?

Well Yes! it can be any number except for 0 since it also means false.

So what condition will make the while loop not infinite?

answer: 0 and false plus others depending on the condition of the loop.

Hope this helps.

Why 1?

I think since 1 stands for true in bool.

Here's the code if you want to try
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include<iostream>

int main(){
        char s = 'x';
        //int s = 0;
        //int s = 1;
        //int s = 3;
        //int s = -2;
        //string s = "x";
        //bool s = false;
        //bool s = true;
        //double s = 0.00;
        //many more...
	while(s)
	{
		std::cout<<"infinite ";
	}
}
wow a bluecoder LOL
Thanks all of you .
Topic archived. No new replies allowed.
Pages: 12