Explain opening files for reading only in c, Computer Engineering

Assignment Help:

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;

 

 


Related Discussions:- Explain opening files for reading only in c

What is the difference between activity and sequence diagram, The following...

The following are the difference among Activity and Sequence Diagrams: A sequence diagram represents the way of processes implement in a sequence. For example, the order of op

What are invisible components, They are light weight components that do no ...

They are light weight components that do no painting, but can take space in the GUI. This is mainly used for layout management.

Mips simulator: testing, Your code will be tested using a command script. T...

Your code will be tested using a command script. The script is available on Blackboard in the archive MIPSimTest.zip. It contains a ReadMe file that explains how to run the script

Assignment, what is an interface and perpheral device

what is an interface and perpheral device

Target _self, TARGET = "_self" "_self" puts the new document in the s...

TARGET = "_self" "_self" puts the new document in the same window and frame as current document. "_self" works the same as if you hadn't used TARGET at all.

Game playing - artificial intelligence, Game Playing: We have now disp...

Game Playing: We have now dispensed with the necessary background material for AI problem solving techniques, and we just considered to looking at particular types of problems

Which of the memory is volatile memory, Which of the memory is volatile mem...

Which of the memory is volatile memory ? Ans. A volatile memory is RAM. Term Volatile memory implies the contents of the RAM get erased as soon as the power goes off.

Design a xnor gate and define its work, N number of XNOR gates is linked in...

N number of XNOR gates is linked in series that is the N inputs (A0, A1, A2......) are specified in the subsequently way: A0 and A1 to first XNOR gate and A2 and O/P of First XNOR

Propositional truth tables, Propositional truth tables: There {X\t} is...

Propositional truth tables: There {X\t} is a substitution that replaces all occurances of variable X with a term representing an object t as:  ∀X. A is true if and only

Eliminating hazards - computer architecture, Eliminating hazards of pipeli...

Eliminating hazards of pipeline -  computer architecture: We can delegate the work of eliminating data dependencies to the compiler, which can fill up in suitable number of NO

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd