C Programming MCQ - File Handling
11. If there is any error while opening a file, fopen will return?
View Answer
12. It is not possible to combine two or more file opening mode in open () method.
View Answer
13. What is the return value of putchar()?
View Answer
14. Which is true?
View Answer
15. What is the purpose of "rb" in fopen() function used below in the code?
FILE *fp;
fp = fopen("demo.txt", "rb");
View Answer
16. Which files will get closed through the fclose() in the following program?
void main()
{
FILE *fp, *ft;
fp = fopen("a.txt", "r");
ft = fopen("b.txt", "r");
fclose(fp,ft);
}
View Answer
17. When fopen() is not able to open a file, it returns
View Answer
18. getc() returns EOF when
View Answer
19. What is the output of this program?
#include <stdio.h>
int main(){
FILE *fp;
char *str;
fp=fopen("demo.txt","r");// demo.txt :you are a good programmer
while(fgets(str,6,fp)!=NULL)
puts(str);
fclose(fp);
return 0;
}
View Answer
20. What is the output of this program?
#include <stdio.h>
int main(){
char c;
FILE *fp;
fp=fopen("demo.txt","r");
while((c=fgetc(fp))!=EOF)
printf("%c",c);
fclose(fp);
return 0;
}
View Answer
Also check :