HI
:?: I want to know, what is the difference between this two structures:
1) if(N=!0)
2) if(N=!0);
I think when we write any instruction after form 1, it means they depends on the condition. But in form 2 there isn't any relation between the condition and instructions. WHAT IS YOUR IDEA?:idea:
What will happen if we write like form 2 ...?
if(N=!0){
//do something
//do something else
//and something else
//.....
}
if(N=!0){
}
Code C - [expand] 1 2 3 4 if ( a == b ) { // empty }
Code C - [expand] 1 if ( a == b );
You can dig a big hole for yourself if you aren't careful about the difference between = and ==. Similarly the difference between =! and != and ==!
Keith
He is asking to being better, you should share your knowledge to help him.
If you don't want to answer, then it's fine. But don't give such answer which can depreciate anyone.
which is a statement I would agree with, but then it assumes the statements haven't been written incorrectly in the first place.I would put it like that: they're both useless.
Well, I believed my original post would be helpful as I don't know the intended purpose of the statement and it could be that someone has mistakenly written =! when they mean != or ==!. I have know way of knowing.
Other than that I don't see the point in me repeating what has already been said such as:
which is a statement I would agree with, but then it assumes the statements haven't been written incorrectly in the first place.
There seems to be a lot of confusion in this thread with some assumptions about the purpose of the statement but the original poster has never come back to clarify it or comment on the suggestions so far.
Keith.
In codevision compiler both these 2 forms are possible & it doesn't have error.Hi
You can't use form 2, you will get an error..
HI
Oh! I am so sorry to come back late. Excuse me please (There were some problems)
as you said,I wrote "=!" mistakenly, in fact I mean "==!" .
But I have a problem! :???:
What is the difference between != or !== or =! ? Do they have their own meaning by itself or some of they don't have any meaning? Which one is true? and Which one should be used in C structure?
Thank you;-)
Keith's right. Writing an if statement and suddenly ending it with a statement end char (which in C/C++ and most languages is ';' ) is not allowed at all. The compiler would for sure stop compiling and give you an error. If you really want to make a null if statement then you have to use the empty brackets trick:(...) but then it assumes the statements haven't been written incorrectly in the first place.
if (N==!0) { /*see, it's empty */ }
if (N == !0)
RunWhenIfHasTRUECondition(); // will be executed only when the if condition is TRUE
else
RunWhenIfHasFALSECondition(); // will be executed only when the if condition is FALSE
// the next code will be executed anyway because it's not part of the IF statement code
MyVar=12345;
OtherFunction();
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?