Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

struct Foo { char *pName; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); strcpy(obj->pName,"Your Name"); printf("%s", obj->pName); } a. Your Name b. compile error c. Name d. Runtime error

3 Answers   HCL,


enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }

2 Answers  


main() { int i=5,j=10; i=i&=j&&10; printf("%d %d",i,j); }

1 Answers  


char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 Answers  


int a = 10 + 10 .... ,... A = A * A What would be the value of A? The answer is 120!! Could anyone explain this to me.

2 Answers   Bosch, eInfochips, HCL, IHCL,






write a c program to Create a registration form application by taking the details like username, address, phone number, email along with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 5 users and display the details. In place of password display “****”. (Use Structures).

0 Answers   CDAC, College School Exams Tests,


Write a procedure to implement highlight as a blinking operation

2 Answers  


main() { struct date; struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }

1 Answers  


WAP to display 1,2,3,4,5........N

2 Answers  


what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }

3 Answers   Wipro,


void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }

3 Answers   Accenture,


main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }

1 Answers  






Categories