C Language - Files

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

 
37.

#include<stdio.h>
#include <errno.h>
int main()
{
errno = 0;
FILE *fb = fopen("/home/jeegar/","r");
if(fb==NULL)
printf("its null");
else
printf("working");
printf("Error %d \n", errno);
}

A. its null B. Working
C. workingError 0 D. workingError 1




38.

Will the following code compile? If yes, then is there any other problem with this code?

#include
void main(void)
{
char *ptr = (char*)malloc(10);
if(NULL == ptr)
{
printf("\n Malloc failed \n");
return;
}
else
{
// Do some processing
free(ptr);
}
return;
}

A. The code will compile error free but with a warning B. The code will compile without a warning
C. The code will not compile D. None of these




39.

Following code is Add text to a file which already exists and there is some text in the file.is it correct r not

#include
int main()
{
FILE *fp
file = fopen("file.txt","a");
fprintf(fp,"%s","This is just an example :)"); /*append some text*/
fclose(fp);
return 0;
}

A. correct B. wrong
C. Gives Comiplation error D. Gives Run time error




40.

if(student_file = fopen("s.dat", "w")) == NULL) {
/* do this */
) else {
/* do that */
}
The type of "student_file" should be

A. file B. int
C. float D. FILE *




41.

Consider the following program fragment,

assuming the #include directive:
FILE *stream;
textfile = "file.txt";How could the file file.txt (present in the current directory) be opened for reading?

A. stream = fopen(textfile, "r"); B. textfile = fopen(stream, "r");
C. fopen(stream.textfile, r); D. file.txt = fopen(*stream, "r");




« previous

1

2

3

4

5

6

7

 
 
 



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