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 are the properties of electronic cash, What are the properties of elec...

What are the properties of electronic cash? Properties: 1. Monetary Value: Monetary value should be backed by bank certified cashier’s cheque or cash, bank authorized cred

Show the major benefits of microprocessor, Q. Show the Major benefits of mi...

Q. Show the Major benefits of microprocessor? Microprocessor is a complete CPU on a single chip. The major benefits of microprocessor are:  Powerful butCompact; can

What is program controlled i/o, What is program controlled I/O? In prog...

What is program controlled I/O? In program controlled I/O the processor repeatedly checks a status flag to achieve the needed synchronization among the processor and an input a

Explain the term - integrity, Explain the term - Integrity In most c...

Explain the term - Integrity In most cases, corporate data should remain unchanged by third parties, so the system should be capable of ensuring that only authorised personn

Define the public and extrn directives- assembler directives, Define the PU...

Define the PUBLIC and EXTRN directives- Assembler directives PUBLIC and EXTRN directives are very significant to modular programming. PUBLIC used to declare that labels of data

Dataflow computing, Dataflow Computing A different to the von Neumann m...

Dataflow Computing A different to the von Neumann model of computation is the dataflow computation model. In a dataflow model, control is fixed to the flow of data. The order o

What is a spanning tree, What is a spanning Tree? A spanning tree is a ...

What is a spanning Tree? A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree

What is the use of status command, What is the use of status command, data ...

What is the use of status command, data output command, and data input command. A status command is used to test a variety of status conditions in the interface and the periphe

The concept of process-parallel computing, The Concept of Process Infor...

The Concept of Process Informally, a method is a program in execution, behind the program has been loaded in the main memory. However, a method is more than just a program code

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