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().
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 |
#define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); }
void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit=--giveit); }
Which version do you prefer of the following two, 1) printf(ā%sā,str); // or the more curt one 2) printf(str);
main() { show(); } void show() { printf("I'm the greatest"); }
write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"
main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }
main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above
What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql
main() { printf("\nab"); printf("\bsi"); printf("\rha"); }
write a c-program to display the time using FOR loop
Program to Delete an element from a doubly linked list.
4 Answers College School Exams Tests, Infosys,
what will be the position of the file marker? a: fseek(ptr,0,SEEK_SET); b: fseek(ptr,0,SEEK_CUR);