Is it possible to use the IF statement over several lines?
Because i have quite afew conditions that have to be met in order
to continue my program.....
And if i put them all in it stretches right across the screen.
Thanks
Boontune
Is it possible to use the IF statement over several lines?
Because i have quite afew conditions that have to be met in order
to continue my program.....
And if i put them all in it stretches right across the screen.
Thanks
Boontune
More like:
Code:if ( Condition || Condition || Condition ) { /* Something here */ }
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
You can do this with anything, as long as there's no ';' it assumes
the line is not finished yet and move's on to the next line.
A big argument list for example.
Code:void blab(int a,int b,int c,int d,int e,int i,int f,int g,int z,int x, int r,int y);
You can also do this with a string (use the \ character to separate the string):
Code:int main(void) { char a[] = "Hello " \ "worl" \ "d!"; printf("%s\n", a); return 0; }
Code:// This can be done if(condition1) { statement1; } else if(condition2) { statement2; } else { statement3; } // This also can be done if(condition1) { if(condition2) { if(condition3) { statement1; statement2; .................. } } }
Last edited by shiv_tech_quest; 01-22-2003 at 07:53 AM.
Have a wonderful day.... and keep smiling... you look terrific that way
signing off...
shiv... as i know him
The way i understand it he has many conditions for his IF
statement, therefore they don't all fit on 1 line, si he'd like
to know if he could go on the next line with conditions.
Answer is sure.
Thats right !
But i think it was answered on the second post!
Cheers guys!
Just one more thing, whats the function called for checking punctuation?
>>whats the function called for checking punctuation?
Care to expand your question a little?
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Yeah sorry,
I mean in the header file ctype.h, there are functions you can use to check conditions, ie.
isdigit() - to check numbers
isalpha() - for letters
I need to know what the one for punctuation is?
... and in your crossposted thread, I told you to open your ctype.h file and look! You will find what you want, and a load of other stuff.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
You could code a function on your own if the one you are searching is not existingOriginally posted by boontune
Yeah sorry,
I mean in the header file ctype.h, there are functions you can use to check conditions, ie.
isdigit() - to check numbers
isalpha() - for letters
I need to know what the one for punctuation is?
Code:bool ispunctuation(char ch) { return (ch == '\''); // since ' (quote / punctuation) has a special meaning, we need to use the a quote then a slash (backward) then a quote then another quote }
Last edited by shiv_tech_quest; 01-22-2003 at 08:30 AM.
Have a wonderful day.... and keep smiling... you look terrific that way
signing off...
shiv... as i know him
hehe sorry mate,
I have just look in ctype.h
Thanks alot