C Language file reading and writing

Source: Internet
Author: User

//read this section of the file to get command line arguments to read    intch; FILE*FP; unsignedLongCount =0; if(argc!=2) {printf ("no parameters \ n");    Exit (Exit_failure); }    if((Fp=fopen (argv[1],"R"))==NULL) {printf ("file has no content \ n");    Exit (Exit_failure); }     while((CH=GETC (fp))! =EOF)        {PUTC (ch,stdout); //It 's the same meaning as the sentence.//Putchar (CH);count++;    } fclose (FP); printf ("\ n"); printf ("file%s has%lu characters \ n", argv[1],count); //Write to File    Char*s="That ' s good news";/*defines a string pointer and initializes*/    intI=617;/*defining an Integer variable and initializing it*/FILE*FP;/*Defining file Pointers*/FP=fopen ("Test.dat","W");/*Create a text file to write only*/fputs ("Your score of Toeflis", FP);/*write a string of characters to the file you built*/FPUTC (':', FP);/*write a colon to the file you built:*/fprintf (FP,"%d/n"+ N);/*write an integer number to the file you have built*/fprintf (FP,"%s", s);/*write a string to the file you built*/fclose (FP); /*Close File*/

C Language file reading and writing

Related Article

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.