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

Is the following code legal? void main() { typedef struct a aType; aType someVariable; struct a { int x; aType *b; }; }

1 Answers  


main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(“%d” ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(“%d ” ,*p); p++; } }

1 Answers  


main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }

1 Answers  


void main() { int i=5; printf("%d",i++ + ++i); }

3 Answers  


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

1 Answers  


main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }

2 Answers   Persistent,


void main() { int i=5; printf("%d",i+++++i); }

3 Answers  


Display the time of the system and display the right time of the other country

1 Answers  


How do I write a program to print proper subset of given string . Eg :input: abc output:{},{a},{b},{c},{a,b},{a,c},{b,c}, {a,b,c}.I desperately need this program please mail me to saravana6m@gmail.com

11 Answers   Deshaw, Infosys,


void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }

1 Answers  


main() { static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s",names[i]); }

2 Answers  


find simple interest & compund interest

2 Answers  


Categories