answersLogoWhite

0

Here's the program:

/* Program Start */

#include <stdio.h>

int main (void)

{

FILE *handler; // The "*handler" can be named as anything as you desired

char arrText[1000];

handler = fopen("Sampletext.txt", "r"); // We opened a file "Sampletext.txt" ready for reading

scanf ("%s", &arrText); // Scan the first line of the file

printf ("%s", &arrText); // Display the scanned data from file, to the console

fclose (handler);

return 0;

}

/* Program End */

If you wish to print the scanned line to text and not to console, use fprintf insted. fprintf can be executed in this form: fprintf (<file name>, "<format specifier> (or text)", <variable>);

Also, use "a" in fopen. This will append the current data to the text file.

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


Write a PHP program to read and write a text file?

Oh this is easy =PLets say or file is "file.txt"


What are typical access rights that may be granted or denied to a particular user for a particular file?

Read, write, execute, and functions in software objects.


Write java program to merge alternate lines from file1 and file2 into file1?

I suggest something like this:* Open file1 and file2 * Create a temporary output file, for writing * Read a line from file1, write it into the output file * Read a line from file2, write it into the output file * Repeat the previous two steps, while you are not at end-of-file in either of the two files * At this point, if you are NOT at end-of-file in file1, read the remaining lines of file1, and write them to the output (you can write a loop for this). * Similarly, if you are NOT at end-of-file in file2, read and write the remaining file. * Close file1, file2, and the output file. * Copy the temporary output file back to file1 * Erase the temporary output file


What is meant by read and write txt in file handling?

read: moving data from file to memory write: moving data from memory to file


What file systems does Ubuntu support?

Ubuntu supports a large number of file systems, including ext2 (read/write), ext3 (read/write), ext4 (read/write), ReiserFS (read/write), JFS (read/write), XFS (read/write), FAT (read/write), and NTFS (read, additional software available for writing). With the exception of NTFS, it can also boot off of the above file systems.


What is a compatible file?

A compatible file is a file name extension (or format) that a program can read.


What program do you use to read txt file?

A .txt can be read with notepad.


How to write a C program to find the header record in a file .please advice?

Just open the file, read-in N bytes and then examine (parse) for known header values or signature.


What is the difference between read and write in computer programming?

A "Read" operation occurs when a computer program reads information from a computer file/table (e.g. to be displayed on a screen). The "read" operation gets information out of a file (some computer languages use the term "get" instead of "read"). After a "read", the information from the file/table is available to the computer program but none of the information that was read from the file/table is changed in any way. A "Write" operation occurs when a computer program adds new information, or changes existing information in a computer file/table. An example of a computer program adding new information to a file would be when a company adds a new hire's details into its employee master file. An example of a computer program changing existing information would be when a company updates its employee master file if an existing employee changes their address. In this example, since the employee already existed in the employee file, the computer program would have had to perform a "read" at some point, to get the information out of the file/table (a fundamental rule of computer programming is that you can't update a record in a file/table unless you perform a "read" operation to get a hold of that record in the first place). Either way, the "Write" operation is what puts information in to a file. Some computer languages use the terms "put" or "update", but these are both "write" operations in general IT terms. Bottom line: Read = get information. Write = add or change information. HTH


How do you read and write video file in java?

you can use inputstream for reading the file java.io.fileinputstream and write the file using outputstream..


What abilities does the NTFS write permission grant?

Write to the file, append to the file, and read or change its attributes.