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

Hybrid model, The hybrid models are mostly tailormade models suiting to exa...

The hybrid models are mostly tailormade models suiting to exact applications. Actually these fall in the category of mixed models. Such type of application-oriented models keep cro

How semaphores implement mutual exclusion, How semaphores implement mutual ...

How semaphores implement mutual exclusion? Mutual-exclusion implementation along with semaphores: Assume that there are n-processes and they share a semaphore, mutex (stan

Translator for low level programming language, Translator for low level pro...

Translator for low level programming language were termed as? Ans. Translator for low level programming language is called as Assembler.

What data structure is used by an operating system, What data structure is ...

What data structure is used by an operating system to keep track of process information? Explain A data structure termed as process control block (PCB ) is used by an operat

Give difference between compiler and interpreter, Give difference between c...

Give difference between compiler and interpreter. Compiler: It is a translator for machine independent HLL as FORTRAN and COBOL etc. Interpreter: It analysis the source

Poor technology or system requirements definition, Poor Technology or Syste...

Poor Technology or System Requirements Definition - Information System Previously we looked at product design and specifically the importance of requirements capture as part o

Sem 4, Which are the subject of sem 4?

Which are the subject of sem 4?

Define asynchronous bus, Define asynchronous bus. Asynchronous buses ar...

Define asynchronous bus. Asynchronous buses are the ones in which every item being transferred is accompanied by a control signal that shows its presence to the destination uni

How and what data is gathered- simulation, How and what data is gathered- S...

How and what data is gathered- Simulation To make this as realistic as possible, data is required to be gathered over a long period of time. This can be done by sensors near/i

Produce a sequence diagram for the task add, This assignment is based on th...

This assignment is based on the 'Swansea Docklands Heritage Society' case study attached.  The assignment is the third of three related submissions, all based on the Swansea Dockla

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