int main()
{
int x=10;
printf("x=%d, count of earlier print=%d",
x,printf("x=%d, y=%d",x,--x));
getch();

}
==================================================

returns error>> ld returned 1 exit status
===================================================
Does it have something to do with printf() inside another
printf().



int main() { int x=10; printf("x=%d, count of earlier print=%d", ..

Answer / kurt s

The code example is horrendous. But the answer:

No, it doesn't have to deal with the nested printf statements. The printed statement would look something like this:

x=9, y=9x=9, count of earlier print=8

it places the first printf's arguments on the stack, which includes another call to printf, which is placed on top. The variable x gets predecremented, so when the nested printf starts to print, x will be 9. Before the outer printf can be called, the inner printf needs to return, and printf returns an int equal to the length of the outputted string, which is "x=9, y=9", a string of length 8. Note that this is still sent to STDOUT, printing to the screen.

The outer printf call looks like this now:

printf("x=%d, count of earlier print=%d", 9, 8);

Which prints "x=9, count of earlier print=8" to STDOUT, right after the inner printf's output, giving the string mentioned toward the top of this answer.

ld returned 1 exit status usually means there are unresolved symbols.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

2 Answers  


programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h

1 Answers  


write a program to count the number the same (letter/character foreg: 's') in a given sentence.

2 Answers  


Write a program using one dimensional array to assign values and then display it on the screen. Use the formula a[i]=i*10 to assign value to an element.

1 Answers   Samar State University,


#include<stdio.h> main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); }

1 Answers  






Cluster head selection in Wireless Sensor Network using C programming language.

0 Answers  


how to concatenate the two strings

1 Answers  


how to delete an element in an array

2 Answers   IBM,


main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10

4 Answers   HCL,


How can u say that a given point is in a triangle? 1. with the co-ordinates of the 3 vertices specified. 2. with only the co-ordinates of the top vertex given.

1 Answers  


how to test pierrot divisor

0 Answers  


void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }

1 Answers  


Categories