Printf can be implemented by using __________ list.

Answers were Sorted based on User's Feedback



Printf can be implemented by using __________ list...

Answer / susie

Answer :

Variable length argument lists

Is This Answer Correct ?    17 Yes 1 No

Printf can be implemented by using __________ list...

Answer / sagar arora

variable length argument lists,for more information checked
out in Dennis Ritchie book.u can write ur own printf.

Is This Answer Correct ?    6 Yes 1 No

Printf can be implemented by using __________ list...

Answer / navneet

using Variable length argument lists :
Let us see how

Use vprintf, vfprintf, or vsprintf.

Here is an "error" routine which prints an error message, preceded by the string "error: " and terminated with a newline:

#include <stdio.h>
#include <stdarg.h>

void
error(char *fmt, ...)
{
va_list argp;
fprintf(stderr, "error: ");
va_start(argp, fmt);
vfprintf(stderr, fmt, argp);
va_end(argp);
fprintf(stderr, "\n");
}
To use the older <varargs.h> package, instead of <stdarg.h>, change the function header to:

void error(va_alist)
va_dcl
{
char *fmt;
change the va_start line to

va_start(argp);
and add the line

fmt = va_arg(argp, char *);
between the calls to va_start and vfprintf. (Note that there is no semicolon after va_dcl.)

References: K&R II Sec. 8.3 p. 174, Sec. B1.2 p. 245; H&S Sec. 17.12 p. 337; ANSI Secs. 4.9.6.7, 4.9.6.8, 4.9.6.9 .

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Code Interview Questions

int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }

2 Answers   CSC,


Is the following code legal? struct a { int x; struct a b; }

1 Answers  


main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }

1 Answers  


void main() { int i=i++,j=j++,k=k++; printf(“%d%d%d”,i,j,k); }

1 Answers  


Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];

1 Answers  






{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

4 Answers  


void main() { int x,y=2,z; z=(z*=2)+(x=y=z); printf("%d",z); }

4 Answers  


Write a program to receive an integer and find its octal equivalent?

7 Answers  


main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

2 Answers  


what is variable length argument list?

2 Answers  


Is there any difference between the two declarations, 1. int foo(int *arr[]) and 2. int foo(int *arr[2])

1 Answers  


Write a prog to accept a given string in any order and flash error if any of the character is different. For example : If abc is the input then abc, bca, cba, cab bac are acceptable, but aac or bcd are unacceptable.

5 Answers   Amazon, Microsoft,


Categories