Add lines to your code

Source: Internet
Author: User

I checked the file control in C language and wrote a number of lines to display.

 

After processing each line of characters read with an array, printing is what I want. The thought is very simple, but it is not implemented ,.~~~ I used another method ..

Code:
  1. # Include <stdio. h>
  2. # Include <stdlib. h>
  3. # Include <conio. h>
  4. # Define size 250
  5. Int mark = 0;
  6. Int main ()
  7. {
  8. File * FPR, * FPW;
  9. Char filename [size];
  10. Char buff [size];
  11. Char put1 = ':';
  12. Puts ("enter the name of the file to be annotated ");
  13. Gets (filename );
  14. Fflush (stdin );
  15. If (FPR = fopen (filename, "R") = NULL)
  16. {
  17. Fprintf (stderr, "error opening to file ");
  18. Exit (1 );
  19. }
  20. If (FPW = fopen ("file .txt", "W") = NULL)
  21. {
  22. Fprintf (stderr, "error opening to file ");
  23. Exit (1 );
  24. }
  25. Puts ("the comment file is as follows ");
  26. While (! Feof (FPR ))
  27. {
  28. Fgets (buff, size, FPR );
  29. Printf ("% d", ++ mark );
  30. Printf ("% C", put1 );
  31. Printf ("% s/n", buff );
  32. Fprintf (FPW, "% d", mark );
  33. Fputc (put1, FPW );
  34. Fputs (buff, FPW );
  35. }
  36. Fclose (FPR );
  37. Fclose (FPW );
  38. Return 0;
  39. }

 

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.