opening files for reading only a


Opening Files for Reading Only    : A data file is a file that you can open and read its contents visually - for example, C source files, .dat files, HTML etc - anything that looks "neat" in Notepad. A binary file is a file that is written in machine code - usually seen as a mass of weird characters in Notepad! Examples are bitmaps, executables etc. To open a data file for reading only, pass "r" as the second argument of fopen, as demonstrated in this example:

#include

int main()

{

FILE *file; /* declare a FILE pointer */

file = fopen("data/hello.dat", "r");

/* open a text file for reading */

if(file==NULL)

{

}

else

{

}

}

printf("Error: can't open file.\n");

fclose(file); /*DON'T PASS A NULL POINTER TO fclose !! */

return 1;

 

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: opening files for reading only a
Reference No:- TGS0305448

Expected delivery within 24 Hours