0
Why it prints 3 instead of 6 and also with space?
void main() { printf("ABC %d",printf("ABC")); }
2 Antworten
+ 2
Chetan Mude for inner printf , you are asking to store value of function return as %d of outer printf...
hence, first inner printf ABC is printed and that function returns size of characters which is 3... then outer printf prints abc and that size we are not capturing anywhere to print..
it's like below example:
int add(int a,int b) {return a+b;}
int main ()
{
int x = add(3,4);
add(5,7);
return 0;
}
here , first function call result is stored in variable x but second function call is returning result but we are not storing it...
hih
+ 1
The inner printf() function is executed first, printing “ABC”. Moreover it returns the length of the string to the outer printf() function, which is 3. Then the outer printf() function outputs “ABC 3”.