Error Handling
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
char buff[25];
stderr = stdin;
fscanf(stderr, "%s", buff);
printf("%s\n", buff);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Whatever user types
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
FILE *fp = stdout;
stderr = fp;
fprintf(stderr, "%s", "Interveiw Mania");
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Interveiw Mania
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
FILE *fp;
char ch;
int num = 0;
fp = fopen("file1.txt", "r");
while (!feof(fp))
{
ch = getc(fp);
putc(ch, stdout);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Segmentation fault
- Within main, return expr statement is equivalent to ________
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
exit(expr)
- What is the output of the following C code if there is no error in stream fp?
#include <stdio.h>
int main()
{
FILE *fp;
fp = fopen("file1", "w");
printf("%d\n", ferror(fp));
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
0