C - Functions - Discussion

You Are Here :: Home > C > Functions - Discussion

 



Q.

If int is 2 bytes wide.What will be the output of the program?

#include
void fun(char**);
int main()
{
char *argv[] = {"ab", "cd", "ef", "gh"};
fun(argv);
return 0;
}
void fun(char **p)
{
char *t;
t = (p+= sizeof(int))[-1];
printf("%s\n", t);
}

A. ab B. cd
C. ef D. gh

Answer: Option B
Explaination:

Since C is a machine dependent language sizeof(int) may return different values.



Discussion

Your Comments Goes here...
NameDiscussion