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

Write statement, Rounding off of values can be carried out using the write ...

Rounding off of values can be carried out using the write statement. Yes, Rounding off value can be out by using the write statement.

What is the function of an ip packet screening router, What is the function...

What is the function of an IP packet screening Router? Explain with the help of a diagram. Function of an IP Packet Screening Router: A screening router is the most fund

Functions of an operating system, a) In multitasking Operating Systems, th...

a) In multitasking Operating Systems, there are two types of multitasking such as the "Preemptive Multitasking" and the "Cooperative Multitasking". Describe the two mentioned mult

fisherpersons are not over-fishing, Prepare the Relational Tables to signi...

Prepare the Relational Tables to signify the following situation, which is defined by means of text and an Entity Relationship Diagram. Note: Do not attempt to vary the ERD. Yo

Define cloud services with example, Define Cloud services with example. ...

Define Cloud services with example. Any web-based application or service offered by cloud computing is known as a cloud service. Cloud services can contain anything from calend

Concept of mouse, The concept of Mouse was designed by Douglas C. Engelbart...

The concept of Mouse was designed by Douglas C. Engelbart of Stanford Research institute and first Mouse was designed by Xerox corporation.  Mouse itself is a device that gives you

Determine the term queries-DBMS, Determine the term Queries-DBMS Querie...

Determine the term Queries-DBMS Queries most commonly allow information to be retrieved from tables. As the information is often spread across numerous tables, queries allow it

Convert statement into conjunctive normal form , Consider the following sta...

Consider the following statements about the types of fruit people like. If people like apples, then they do not like oranges. If people do not like apples, then they like orang

State about the harvard mark I and the bug, Harvard mark i and the bug ...

Harvard mark i and the bug The next important effort towards devising an electromechanical computer was done at the harvard University, jointly sponsored by the Department of U

What is hit and hit rate , What is hit? A successful access to data in ...

What is hit? A successful access to data in cache memory is known as hit. Normal 0 false false false EN-IN X-NONE X-NONE

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