C Programming language Exercises 1-10

Source: Internet
Author: User

Practice 1-10 Write a program that copies the input to the output, replaces the lifting tab with \ T, replaces the fallback character with the \b, and replaces the backslash with \ \. This allows you to display tab and fallback characters in a visible way.

The code is as follows:

#include <stdio.h>//contains information about the standard library. #include<conio.h>intMainvoid)//defines a function named Main, which does not accept parameter values. {printf ("====== replaces the tab characters in the input with \ t, the return character is replaced by \b, and the backslash is replaced with \\======\n"); //int C; //GetChar () is cached, so \b are directly functioning, so the program does not display ' \b '.     /*while ((c = GetChar ()) = EOF) {//Here the character is judged and replaced by If-else.        if (c = = ' \ t ') printf ("\\t");            else if (c = = ' \b ') printf ("\\b");        else if (c = = 8) printf ("\\b");        else if (c = = ' \ \ ') printf ("\\\\");    else Putchar (c); }*/    //In This example, when the user enters a return event, the input is terminated, the characters are replaced immediately, and the input is not copied to the output program.     /*while ((c = getch ())! =) {if (c = = ' \ t ') printf ("\\t");        else if (c = = ' \b ') printf ("\\b");        else if (c = = ' \ \ ') printf ("\\\\");    else Putchar (c); }*/        //Getch (); //prevent the console from flashing through, you need to accept any characters after you close the console. //return 0; //returns a shape to the execution environment, and 0 represents a successful execution. //This topic involves the control of the virtual terminal, the program needs to use a specific API to get backspace. //References:http://www.zhihu.com/question/21658256/answer/18986712    /*int ch;        do {ch = _getch ();    printf ("%c\n", ch); } while (1);*/    //return 0; //The above code is key to the _getch () function. Reference _getch, _getwch}

Personal Understanding:

The fallback character in this topic has not been implemented according to the requirements of the topic, pending processing.

When you use the GetChar () function, the type fallback immediately takes effect on the buffer and eventually does not get the fallback character.

When you use Getch (), you get a fallback character, but you do not complete the exercise to copy the input to the output .

C Programming language Exercises 1-10

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.