C Language - Files

You Are Here :: Home > C Language > Files - General Questions

 
31.

What will be the output of the program ?

#include
int main()
{
FILE *fs, *ft;
char c[10];
fs = fopen("source.txt", "r");
c[0] = getc(fs);
fseek(fs, 0, SEEK_END);
fseek(fs, -3L, SEEK_CUR);
fgets(c, 5, fs);
puts(c);
return 0;
}

A. things B. thing
C. ngs D. Error in fseek();




32.

Identify X library function for line input and output?

#include
int X(char *s, FILE *iop)
{
int c;
while (c = *s++)
putc(c, iop);
return ferror(iop) ? EOF : 0;
}

A. getc B. putc
C. fgets D. fputs




33.

What is the output of this C code?

#include
int main()
{
int n;
scanf("%d", &n);
ungetc(n, stdin);
scanf("%d", &n);
printf("%d\n", n);
return 0;
}

A. Compile time error B. Whatever is typed by the user first time.
C. Whatever is typed by the user second time D. Undefined behaviour




34.

What will be the content of 'file.c' after executing the following program?

#include
int main()
{
FILE *fp1, *fp2;
fp1=fopen("file.c", "w");
fp2=fopen("file.c", "w");
fputc('A', fp1);
fputc('B', fp2);
fclose(fp1);
fclose(fp2);
return 0;
}

A. B B. A
C. 0 D. Error in opening file 'file1.c'




35.

What is the output of this C code?

#include
int main(){
FILE *fp1,*fp2;
fp1=fopen("1.text","r");
fp2=fopen("2.txt","r");
fclose(fp1,fp2);
return 0;
}

A. fp1 Closed B. fp2 Closed
C. 0 D. Compiler error




36.

W

#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main()
{
struct stat statbuf;
FILE *fb = fopen("/home/jeegar/","r");
if(fb==NULL)
printf("its null\n");
else
printf("not null\n");
stat("/home/jeegar/", &statbuf);
if(S_ISDIR(statbuf.st_mode))
printf("directory\n");
else
printf("file\n");
return 0;
}

A. its null directory B. not null directory
C. 0 D. Compile time error




« previous

1

2

3

4

5

6

7

next »

 
 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on