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

Why floating point numbe process than integer, Why floating point number mo...

Why floating point number more difficult to represent and process than integer? In floating point numbers we have to show any number in three fields sign, exponent and mantissa

Write an applet that display the directory holding html file, Write an appl...

Write an applet that display the directory holding the HTML file that started the applet and the directory from which, applet class file was loaded. An applet is here given bel

Uml, what is uml ?

what is uml ?

What are the measures to be taken in the design, What are the measures or p...

What are the measures or precautions to be taken in the Design when the chip has both analog and digital portions? As today's IC has analog components also inbuilt, some design

Embedded systems and the system in which rtos is running, Explain What is t...

Explain What is the difference among embedded systems and the system in which RTOS is running? Ans) Embedded system can have RTOS and cannot have also. It depends on the requi

How many i/p & o/p a full adder logic circuit will have, A full adder logic...

A full adder logic circuit will have ? Ans. The full adder logic circuit also accounts the carry i/p generated in the earlier stage and it will add two bits. Hence three inputs

Combinatorial and scheduling problems, Combinatorial and Scheduling Proble...

Combinatorial and Scheduling Problems: One class of problems is concerned with specifying optimal scheduled. A classical example is the Travelling Salesperson Problem where

Lexical analyser, The aim of this project is for you to construct a fully w...

The aim of this project is for you to construct a fully working compiler for a small simple programming language, SPL. The compiler will read in SPL source code and produce ANSI C

What is the draw back of micro programmed control, What is the draw back of...

What is the draw back of micro programmed control? It leads to a slower operating speed because of the time it takes to fetch microinstructions from the control store.

Equivalence between vhdl and c, Equivalence between VHDL and C? There i...

Equivalence between VHDL and C? There is concept of understanding in C there is structure.Based upon requirement structure provide facility to store collection of various data

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