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

Explain intermediate representation, a. Explain Intermediate Representation...

a. Explain Intermediate Representation? What are the desirable properties of Intermediate Representation? b. Explain Grammar of a language. Identify the dissimilar classes of gr

#title.calomel electrode, explain the construction and working of calomel e...

explain the construction and working of calomel electrode

What is meant by refreshing of the screen, What is meant by refreshing of t...

What is meant by refreshing of the screen?  Some method is required for maintaining the picture on the screen. Refreshing of screen is completed by keeping the phosphorus glowi

Integrated services digital network service, Whole idea of ISDN is to digit...

Whole idea of ISDN is to digitize the telephone network to permit transmission of video, audio and text over existing telephone lines. The purpose of ISDN is to provide fully integ

What is program annotation packages, Q. What is Program Annotation Packages...

Q. What is Program Annotation Packages? A quite renowned scheme in this field is OpenMP a newly designed industry standard for shared memory programming on architectures with u

Explain about distributed shared memory systems, Explain about Distributed ...

Explain about Distributed Shared Memory Systems? Distributed Shared Memory (DSM) systems emulate a shared memory abstraction on loosely coupled architectures in order to allow

Input output techniques - computer architecture, Input Output Techniques: ...

Input Output Techniques: o   Interrupt driven o   Direct Memory Access (DMA) o   Programmed Programmed I/O   CPU has control over I/O directly   Read/write

Graphic symbol of S-R flip-flop, Q. Graphic symbol of S-R flip-flop? R...

Q. Graphic symbol of S-R flip-flop? R-S Flip flop - Graphic symbol of S-R flip-flop is displayed in Fig below. It has 3 inputs S (set), R (reset) and C (for clock). Q(t+1) is

How can we specify file transfer in a web page, Can we specify file transfe...

Can we specify file transfer in a Web page? Explain with the help of suitable example. Yes, file transfer can be given in a web page. The first field within a URL gives a proto

Analysis the pc configuration, 1) Identify the software needs of each PC an...

1) Identify the software needs of each PC and whether or not anything needs to change. a. State the changes that you would make (and why) b. If no "change" needs to be made b

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