COM 102- COMPUTER PROGRAMMING AND DATA STRUCTURES-(2+1)

Ex. No.: 16

File I/O

Date:

Aim: o

To make use of file I/O in the C program.

Example 1: Write to a text file using fprintf(). Source Code: #include int main() { int num; FILE *fptr; fptr = fopen("program.txt","w"); if(fptr == NULL) { printf("Error!"); exit(1); } printf("Enter an integer number:"); scanf("%d",&num); printf("Open the file program.txt and check the entered number in that file"); fprintf(fptr,"%d",num); fclose(fptr); return 0; }

1

COM 102- COMPUTER PROGRAMMING AND DATA STRUCTURES-(2+1)

Example 2: Read from a text file using fscanf(). Source Code: #include int main() { int num; FILE *fptr; if ((fptr = fopen("program.txt","r")) == NULL) { printf("Error! opening file"); // Program exits if the file pointer returns NULL. exit(1); } fscanf(fptr,"%d", &num); printf("Value of n=%d", num); fclose(fptr); return 0; }

2

COM 102- COMPUTER PROGRAMMING AND DATA STRUCTURES-(2+1)

Example 3: Reading and Writing to File using fprintf() and fscanf(). Source Code: #include struct emp { char name[10]; int age; }; int main() { struct emp e; FILE *p,*q; p = fopen("one.txt", "a"); q = fopen("one.txt", "r"); printf("Enter Name and Age:"); scanf("%s %d", e.name, &e.age); fprintf(p,"%s %d", e.name, e.age); fclose(p); do { fscanf(q,"%s %d", e.name, e.age); printf("%s %d", e.name, e.age); } while(!feof(q)); return 0; } Do it yourself by writing a C program for the following  Create a data file a series of integer numbers, read these numbers and then write all odd and even numbers separately to two other files.  Create a random access file that could store details about five products.

3

Write to a text file using fprintf().

COM 102- COMPUTER PROGRAMMING AND DATA STRUCTURES-(2+1). 1. Ex. No.: 16. File I/O. Date: Aim: o To make use of file I/O in the C program. Example 1: Write to a text file ... printf("Enter an integer number:"); scanf("%d",&num); printf("Open the file program.txt and check the entered number in that file"); fprintf(fptr ...

212KB Sizes 5 Downloads 176 Views

Recommend Documents

convert pdf file to text online free
convert pdf file to text online free. convert pdf file to text online free. Open. Extract. Open with. Sign In. Main menu. Displaying convert pdf file to text online free.

Using the Timed Loop to Write Multirate Applications in LabVIEW™
patents.txt file on your CD, or ni.com/patents. .... AI engine. Use the Source type listbox in the Loop Configuration dialog box to select a timing source or use the ...

Read PDF Ready to Write 1: A First Composition Text Free Online
Text Free Online ... arts amp Literacy in History Social Studies Science and technical Subjects Literacy is traditionally meant as the ... in a variety of possibly intimidating situations starting off Course materials exam information and professiona

pdf file text editor online
File: Pdf file text editor online. Download now. Click here if your download doesn't start automatically. Page 1 of 1. pdf file text editor online. pdf file text editor ...

How to write a resume.pdf
Interest: Blog writing; Driving; Football playing,. Membership: Badhon (Blood donating organization). References. Will be provided upon request. Page 1 of 6 ...

Encrypted Peer to Peer File Sharing System using ...
1Student, Department of Computer Science, SSBT's COET, Bambhori, Jalgaon ... 1. Introduction. Over the past years, the immense popularity of the Internet has produced a significant stimulus .... file's replication degree based on its popularity.

using digital signatures in a pdf file
There was a problem previewing this document. Retrying... Download. Connect more ... using digital signatures in a pdf file. using digital signatures in a pdf file.

Using Marked-up Hebrew Text to Discover Linguistic Patterns
2 Information systems are “[t]he resources that enable the collection, management, control, and dissemination of ... information or may be used to structure the data in the file.3 This latter function, which may be used to simulate .... After editi

Text-Line Extraction using a Convolution of Isotropic ...
... of text-lines. For a sample document image, the smoothing results of isotropic, ... of applying a set of filters, instead of one, for a given data processing task. ..... [12] W. T. Freeman and E. H. Adelson, “The design and use of steerable fil

Distributed File System Using Java
Though previous distributed file system such as Hadoop Distributed File System, ... able to quickly determine if potential users were able to understand the interface object. ... architecture being employed that is either client-server or peer-peer.

Protein Word Detection using Text Segmentation Techniques
Aug 4, 2017 - They call the short consequent sequences (SCS) present in ..... In Proceedings of the Joint Conference of the 47th ... ACM SIGMOBILE Mobile.

Text Extraction Using Efficient Prototype - IJRIT
Dec 12, 2013 - as market analysis and business management, can benefit by the use of the information ... model to effectively use and update the discovered Models and apply it ..... Formally, for all positive documents di ϵ D +, we first deploy its

Text Extraction Using Efficient Prototype - IJRIT
Dec 12, 2013 - Various data mining techniques have been proposed for mining useful Models ... algorithms to find particular Models within a reasonable and ...

Text Tokenisation Using unitok
deals with some language or web data specific tokenisation cases. The ... based analysis (such as word frequency lists, collocations (Word Sketches), ... 9 The lists of language specific abbreviations were taken from the respective Wikipedia.

Text to Text Connections.pdf
item is also bound by copyright laws and redistributing, editing, selling, or posting this item (or any part. thereof) on the Internet are all strictly prohibited without ...

Text file converted with freeware AcroPad - www ...
So he was a bachelor without any home pussy. If she played her cards right, this could turn out to be a bonanza. When she had finished devouring the meal, ...

Text file converted with freeware AcroPad - www ...
streets and sidewalks, autos, parking garages, advertising billboards, monuments ...... disks surrounding the stars Vega and Epsilon Eridam. The hole in the disk ...

What is a hybrid PDF file? How to create a hybrid PDF file - GitHub
How to create a hybrid PDF file. 1. First, create your document in LibreOffice1. You can open any format LibreOffice supports. 2. Now, from the File menu, select ...

edit text pdf file free online
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. edit text pdf file ...