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 open addressing, Open addressing:  The easiest way to resolve a co...

Open addressing:  The easiest way to resolve a collision is to begin with the hash address and do a sequential search by the table for an empty location. The idea is to place the

What is an advantage of executing a process in background, What is an advan...

What is an advantage of executing a process in background? The most common reason to put a process in the background is to permit you to do something else interactively without

Why does ftp use two standard ports, Why does FTP use two standard ports wh...

Why does FTP use two standard ports whereas other protocols, in general use only one port? Justify. File transfer protocol uses a control connection just to send commands and r

What is pure semiconductors, Q. What is Pure semiconductors? Pure semic...

Q. What is Pure semiconductors? Pure semiconductors, known as intrinsic semiconductors, have very few charge carriers and may hence be classified as almost insulators or very p

Explain complex instruction set computer, CISC (Complex Instruction Set Com...

CISC (Complex Instruction Set Computer) CISC stands for Complex Instruction Set Computer. If the control unit having a number of micro-electronic circuitry to make a set of con

Describe language processing activities, Describe language processing activ...

Describe language processing activities? There are two different kinds of language processing activities: a. Program generation activities b. Program execution activities

What is batch processing, What is Batch processing In this process, a n...

What is Batch processing In this process, a number of tasks (or jobs) are all collected together over a set period of time. They are then all loaded into the computer system (i

Define the types of software life cycle, Define the types of software life ...

Define the types of software life cycle Any system progress refers to the initial part of the software life cycle: analysis, design, and implementation. During object oriented

What are different normalization forms, What are different normalization fo...

What are different normalization forms? 1NF: Eliminate Repeating Groups Make a separate table for every set of related attributes, and give each table a primary key. Each fie

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