the function
void fun()
{
char c;
if(c=getchar())!='\n')
fun();
printf("%c",c);
}
Gives the output cba .Can't say why?
himanjim 0 Junior Poster in Training
Recommended Answers
Jump to Post— ~s.o.s~ 2,560the function
void fun()
{
char c;
if(c=getchar())!='\n')
fun();
printf("%c",c);
}
Gives the output cba .Can't say why?This must have happened when you must have given the input "abc" isnt it ?
The above function is basically an example of a recursive function or basically a function which …
Jump to Post— Rashakil Fol 978getch() returns an int, not a char. And there is an open parenthesis missing in the if condition.
int c; if( (c==getchar())!='\n') <snip>I don't see why two people assume that == is the desired operator between c and getchar(). For one, (c==getchar()) will never return a value …
All 5 Replies
FC Jamison 31 Posting Pro in Training Team Colleague
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Rashakil Fol 978 Super Senior Demiposter Team Colleague
Grunt commented: Read Between The Lines :) +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.