C language file read and write operation, reading data from file

Source: Internet
Author: User

Very early write file read and write operation under Linux system, read data from file


#include <stdio.h>int readinfofromfile (const char *strfile) {FILE *fp;char CH;FP = fopen (strfile, "R");// Read-only way to open the file if (fp==null) {perror ("fopen");//Open file failed print error message return-1;} ch = fgetc (FP), while (!feof (FP))//feof read to the end of the file function {putchar (ch);//The characters in the output file ch = fgetc (FP);//Get the next character}fclose (FP);// After using the file remember to close}int main () {char file[20] = "Data.txt"; Readinfofromfile (file);//system ("CP file Data.csv");}


C language file read and write operation, reading data from file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.