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 |
main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }
int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }
union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("\n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); } a. 4, 4, 4 b. 40, 4, 4 c. 1, 100, 1 d. 40 400 4
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().
What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }
program to Reverse a linked list
12 Answers Aricent, Microsoft, Ness Technologies,
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
how to check whether a linked list is circular.
main() { int i=5; printf(“%d”,i=++i ==6); }
main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }
void main() { int k=ret(sizeof(float)); printf("\n here value is %d",++k); } int ret(int ret) { ret += 2.5; return(ret); }
What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }