C language programming exercise reference answer Chapter 8 Document (1)

Source: Internet
Author: User
/* 8.5 enter a line of characters from the keyboard and convert lowercase letters to uppercase letters */
# Include "stdio. H"
Void main ()
{
File * FP;
Char ch;
If (FP = fopen ("C: \ ex85.txt", "W") = NULL)
{
Printf ("cannot create file c: \ ex85.txt ");
Exit (1 );
}
Printf ("enter a line of characters \ n ");
While (CH = getchar ())! = '\ N ')
{
If (CH> = 'A' & Ch <= 'Z ')
Ch = ch-32;
Fputc (CH, FP );
}
Fclose (FP );
Printf ("operation successful ");
}
/* 8.7 connect an ASCII file to another ASCII file. Connect the characters in c: \ ex87_1.txt to c: \ ex87_2.txt */
# Include "stdio. H"
Void main ()
{
File * FP1, * fp2;
Char ch;
If (FP1 = fopen ("C: \ ex87_1.txt", "R") = NULL)
{
Printf ("file c: \ ex87_1.txt cannot be opened ");
Exit (1 );
}
If (fp2 = fopen ("C: \ ex87_2.txt", "A") = NULL)
{
Printf ("the file c: \ ex87_2.txt cannot be opened ");
Exit (1 );
}
While (CH = fgetc (FP1 ))! = EOF)
{
Fputc (CH, fp2 );
}
Fclose (FP1 );
Fclose (fp2 );
Printf ("operation succeeded. Open c: \ ex87_2.txt to view the result ");
}

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.