9.how do you write a function that takes a variable number
of arguments? What is the prototype of printf () function?
10.How do you access command-line arguments?
11.what does ‘#include<stdio.h>’ mean?
12.what is the difference between #include<> and #include”…”?
13.what are # pragma staments?
14.what is the most appropriate way to write a
multi-statement macro?
Answers were Sorted based on User's Feedback
Answer / sumati
9. By using default arguments, we can write a function that
takes a variable number of arguments.
10. By default, 2 arguments are passed to main function..
One is the count that contains number of arguments + 1.
1 is for the program name.
Second argument is the array of arguments...with prgram name
at the first index i.e. [0] and the size of array is count-1.
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / deesha
explained how we can utilize the operator ellipsis (…) to
pass variable number of arguments to a function. I have
utilised there the concept of pointers to access the
variable arguments. The standard C Library provides support
to access these arguments. Use for this support
All you need is to know the last argument before the
ellipsis operator(At least one argument is must to use
variable arguments), let’s call it larg
suppose
fun(type var1,type var2,...)
is a function, then larg corresponds to var2
Now we need to declare the list using va_list
i.e.,
va_list al
now initialize it using va_start
va_start(al,larg);
Now to access each argument, we must know the expected type
of the argument
type var_name = va_arg(al,type);
When we have accessed all the variable arguments, we need to
clean up
va_end(al);
Using standard library, we can easily access the variable
arguments
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / 2028
The above reply is an vague idea for the concept idea some
details may be with an example will be an good input from
nay one of us
Is This Answer Correct ? | 0 Yes | 2 No |
what are advantages of U D F?
There seem to be a few missing operators ..
How do I create a directory? How do I remove a directory (and its contents)?
How can you determine the size of an allocated portion of memory?
code for inverse a matrix
what would be the output of the following prog? Justify your answer? main() { unsigned char ch; unsigned char i; ch = -255; printf("%d",ch); i = -1; printf("%d",i); }
write a program that print itself even if the source file is deleted?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
is forign key will be unique key any table or not?
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
Explain what is wrong in this statement?
? ???Mirror Mirror on the wall????????