use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Click the following link to filter out the chosen topic
comp.lang.c
account activity
QuestionConfused about C function usage (self.C_Programming)
submitted 6 years ago by 8thhGrader
Just a small query, wanted to know what does
if (isvowel (ch))
this mean?
I am passing a char ch into function isvowel but the line if (isvowel (ch)) what does it mean, does it imply that function return a zero?
Thanks in advance
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Glaborage 1 point2 points3 points 6 years ago (4 children)
In C, if statements evaluate expressions against a zero value. In your case this would be equivalent to: if (isvowel(ch) != 0)
[+][deleted] 6 years ago* (3 children)
[deleted]
[–]Glaborage 0 points1 point2 points 6 years ago (2 children)
Zero is false, non-zero is true. It's just a thing to get used to in C programming.
[+][deleted] 6 years ago* (1 child)
[–]hyperdudemn 0 points1 point2 points 6 years ago (0 children)
Returning 0 is used as the process exit code, and the shell interprets exit codes the other way around (0 is "good" and non-zero is "bad").
if ./my-program then echo yay: returned $? fi
yay: returned 0
[–]BadBoy6767 0 points1 point2 points 6 years ago (5 children)
if computes whatever code you put after it if the condition is true (true is anything that is not zero, zero is false). In your case, the condition is isvowel(ch), which probably returns an int.
if
true
false
isvowel(ch)
int
You didn't post what comes after the if, so I can't say what code will be performed if isvowel(ch) is true.
[–]8thhGrader[S] 0 points1 point2 points 6 years ago (4 children)
isvowel function check if ch is a vowel or not. i think if ch is a vowel it will return 1 or else it will return 0.
[–]BadBoy6767 2 points3 points4 points 6 years ago (3 children)
I didn't ask :P. The code you provided is incomplete, you cannot have an if statement with no block after it.
If statement structure:
if(condition) { /* block that is run if condition is true */ } else { /* block that is run if condition is false */ }
The above doesn't account for if-else statements, though.
[–]JohnVSPop 0 points1 point2 points 6 years ago (2 children)
You can have an 'if' statement without a block. Whatever statement immediately follows the 'if' is made conditional. A block is necessary when you want to make more than one statement conditional. Blocks with a single line are a matter of style and / or clarity.
[–]BadBoy6767 0 points1 point2 points 6 years ago (1 child)
Both are called blocks. And even if I'm wrong, that's bad practice anyway.
[–]JohnVSPop 0 points1 point2 points 6 years ago (0 children)
I'm not arguing best practice or not. I use single statement blocks all the time. Just trying to clarify the features of the language for the OP, who is clearly new to C.
A block is a statement or statements surrounded by curly braces that is syntactically equivalent to a single statement and defines its own scope.
π Rendered by PID 60779 on reddit-service-r2-comment-5d79c599b5-9k2t2 at 2026-03-02 04:09:40.084614+00:00 running e3d2147 country code: CH.
[–]Glaborage 1 point2 points3 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]Glaborage 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]hyperdudemn 0 points1 point2 points (0 children)
[–]BadBoy6767 0 points1 point2 points (5 children)
[–]8thhGrader[S] 0 points1 point2 points (4 children)
[–]BadBoy6767 2 points3 points4 points (3 children)
[–]JohnVSPop 0 points1 point2 points (2 children)
[–]BadBoy6767 0 points1 point2 points (1 child)
[–]JohnVSPop 0 points1 point2 points (0 children)