Explain creating files for writing only in c, Computer Engineering

Assignment Help:

Creating Files for Writing Only

Creating Files for Writing Only : To create a text file for writing only, pass "w" into fopen as the second argument. This example follows along the same lines as the previous:

#include

int main()

{

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

file = fopen("data/writing.dat", "w");

/* create a text file for writing */

if(file==NULL)

{

}

else

{

}

}

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

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

return 1;

printf("File created. Now closing it...\n");

fclose(file);

return 0;

Now, if I went into my data folder, I could see a text file called "writing" was created. However, if my data folder didn't exist, an error would occur.

 


Related Discussions:- Explain creating files for writing only in c

What is the difference between = = = and = =, What is the difference betwee...

What is the difference between = = = and = = ? output of "==" can be 1, 0 or X. output of "===" can only be 0 or 1. When you are comparing 2 nos using "==" and if one/bo

Explain concept of temporal parallelism, Concept of Temporal Parallelism  ...

Concept of Temporal Parallelism  In order to make clear what is meant by parallelism inherent in solution of a problem, let's discuss an example of submission of electricity b

Explain language processing, System Software 1. Explain language proces...

System Software 1. Explain language processing? Explain its activities in detail. 2. Discuss briefly about Assembler directives. Also explain about Macro definition and call

Advantage of crc over simple checksum, Why can CRC detect more errors than ...

Why can CRC detect more errors than simple Checksum? There are two purposes a CRC can identify more errors than a simple Checksum. 1. Since an input bit is shifted by all th

Explain about local area network, Q. Explain about Local Area Network? ...

Q. Explain about Local Area Network? Local Area Network (LAN):  It is privately owned communication systems that cover up a small area, say a complex of buildings or school. Le

Representations or languages - artificial intelligence, Representations/Lan...

Representations/Languages Used: Many people are taught "AI" with the opening line: "The three most important things in "AI" are  representation, representation and representat

Loop statement in both the pbo and pai events, Why do we need to code a LOO...

Why do we need to code a LOOP statement in both the PBO and PAI events for each table in the screen? We require coding a LOOP statement in both PBO and PAI events for every ta

Explain program level of parallel processing, Program Level This is nor...

Program Level This is normally the liability of OS (operating system) that runs processes simultaneously. Different programs are generally independent of each other. So paralle

Write C++ for following question., We are planning an orienteering game. Th...

We are planning an orienteering game. The aim of this game is to arrive at the goal (G) from the start (S) with the shortest distance. However, the players have to pass all the che

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