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

Discuss different routing plan adopted in telephone network, Discuss differ...

Discuss different Routing plan adopted in a Telephone network. Hierarchical networks are able of handing heavy traffic where needed, and at similar time use minimal number of t

What is shadow ram, Shadow RAM is a copy of Basic Input/Output Operating Sy...

Shadow RAM is a copy of Basic Input/Output Operating System (BIOS) routines from read-only memory (ROM) into a particular area of random access memory (RAM) so that they can be acc

Write short note on associated vs. common channel signaling, Write short no...

Write short note on Associated vs. Common channel signaling. Associated vs Common channel signalling: The out band signalling suffers from the very restricted bandwidth.

Multiple instruction and multiple data stream (mimd), Multiple Instruction ...

Multiple Instruction and Multiple Data stream (MIMD) In this association, multiple control units and multiple processing elements are prepared as in MISD. But the discrepancy i

E-r diagrams, for ticket reservation in trains for payroll processing for i...

for ticket reservation in trains for payroll processing for insurance database

IEEE802.4 Token Bus Network, en a five station token bus LAN with station a...

en a five station token bus LAN with station addresses of 3000, 500, 100, 70, and 50. Stations with addresses of 5000, 4000, 400, 90, and 60 are waiting to enter the ring. Assume a

Storing a word in memory - computer architecture, Storing a word in Memory:...

Storing a word in Memory: That is similar process with fetching a word from memory. The required address is loaded into the MAR After that data to be written are lo

With respect to security which is the better .net or j2ee, With respect to...

With respect to security, which one is the better choice?.Net or J2EE? Explain? As per majority programmers .NET is the best one which have one vendor compare to, the ease of

Design a 4 to 1 multiplexer, Design a 4 to 1 Multiplexer by using the three...

Design a 4 to 1 Multiplexer by using the three variable function given by F(A, B, C) = ∑ m(1,3,5,6) Ans. The given function F(A,B,C) = ∑ m(1,3,5,6) can be implemented along wit

Draw state diagram, Draw the state diagram of a process from its creation t...

Draw the state diagram of a process from its creation to termination, including all transitions, and briefly elaborate every state and every transition. When a process executes

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