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

Systems analyst in modern business, Many medium-to-large information servic...

Many medium-to-large information services units for modern business have reorganized to be decentralized with an emphasis on dynamic teams andempowerment. In modern business system

Define interrupt, Define interrupt. An interrupt is any exceptional eve...

Define interrupt. An interrupt is any exceptional event that causes a CPUU to temporarily transfer control from its present program to another program , an interrupt handler th

What is dots per inch, Q. What is Dots per Inch? DPI (Dots per Inch) is...

Q. What is Dots per Inch? DPI (Dots per Inch) is a measure for actual sharpness of onscreen image. This relies on both the resolution and size of the image. Practical experienc

Assembly directives and pseudo-ops, Assembly directives and pseudo-ops: ...

Assembly directives and pseudo-ops: Assembly directives are which instructions that executed by the assembler at assembly time, not by the CPU at run time. They can build the

Listening sockets, a) What command do you use to list all listening sockets...

a) What command do you use to list all listening sockets? The output should also contain the name of the program to which the socket belongs.   b) Write the command to use to

Subsequent statements set every element of matrix, Q. Subsequent statements...

Q. Subsequent statements set every element of matrix? Let a= [2,4,6,8,10], b=[1,3,5,7,9], c=[0,0,0,0,0] Consider the subsequent program section FORALL (i = 2:4)   a(i)

Some of the advantages of b2b, Some of the advantages of B2B are: i) En...

Some of the advantages of B2B are: i) Enhanced customer satisfaction Code ii) Enhanced inventory system iii) Simple and cost effective marketing iv) Coordination among

Every sheet in a workbook in excel, Is there a way to apply the same format...

Is there a way to apply the same formatting to every  sheet in a workbook in Excel? Ans)  Yes. To do this, you will require to right click on one of the worksheet tabs and th

Subprogram, create a stored procedure to debit a bank account user must ent...

create a stored procedure to debit a bank account user must enter account no. and amount to debited from account .the minimum balance in account should be 500. if the debited amoun

Paged virtual memory - computer architecture, Paged virtual memory: Mo...

Paged virtual memory: Mostly all implementations of virtual memory divide the virtual address space of an application program into pages; a page is a block that contains conti

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