Question
#include<stdio.h>
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);
}
If int is 2 bytes wide.What will be the output of the program?
#include<stdio.h>
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);
}
Answer: Option B
Was this answer helpful ?
Since C is a machine dependent language sizeof(int) may return different values.
The output for the above program will be cd in Window (Turbo C) and gh in Linux (GCC).
To understand it better, compile and execute the above program in Windows (with Turbo C
compiler) and in Linux (GCC compiler).
Was this answer helpful ?
Submit Solution