常用的转义序列

#include <stdio.h>

#define QUIT  3

int get_menu_choice( void )
{
    int selection = 0;

    do{
        printf( \n1 - Beep );
        printf( \n2 - Display);
        printf( \n3 - Quit);
        printf( \nEnter: );

        scanf( %d, &selection );

     }while ( selection < 1 || selection > 3 );

     return selection;
}

void print_report( void )
{
     printf( \n\nSequence\tMeaning );
     printf( \n\\a\t\tbell (alert) );
     printf( \n\\b\t\tbackspace );
     printf( \n...\t\t...);
}

int main( void )
{
    int choice = 0;

    while (choice != QUIT)
    {
       choice = get_menu_choice();

       if (choice == 1)
           printf(\nBeeping the computer\a\a\a );
       else
       {
           if (choice == 2)
               print_report();
       }
    }
    printf(Bye!\n);

    return 0;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


声明一个计数循环
咕咕咕
#include <stdio.h> int main (void) { printf ("tutorial from book 2s.c om.\\n"); printf ("from book2s.com.\\n");
#include <stdio.h> int main (void) { printf ("Testing...\\n..1\\n...2\\n....3\\n"); return 0;//fromwww.y iiba i .co m
#include <stdio.h> int main (void) { int sum;//fromw w w. yiib ai . com sum = 50 + 25; printf ("The sum of 50 and 25 is %i\\n", sum);
#include <stdio.h> int main (void) { int value1, value2, sum; value1 = 50;/*ww w.yIi ba i. com*/ value2 = 25;
#include <stdio.h> int main()/* from w ww.yi ba I.c om*/ { int planets = 8; int friends = 6; int potterBooks = 7;
要求用户输入浮点,整数并将其打印在屏幕上,以下是代码的实现: #include <stdio.h>
C语言在屏幕上打印一条消息,参考以下实现代码: #include <stdio.h> int main() { printf("this is a test");
#include <stdio.h> int main(void) { int total; int cats; int dogs; int ponies; int others; cats = 4; dogs = 3;
#include <stdio.h> int main(void) { int ch; int ct = 0; while ((ch = getchar()) != EOF) ct++; printf("%d characters read\\n", ct);
switch 不使用 break 语句: #include <stdio.h> int main() { int iResponse = 0; printf("\\n1\\tSports\\n");
#include <stdio.h> int main() { char cResponse = '\\0'; printf("\\na\\tTurn the AC on\\n");
#include <stdio.h> int main() { int iSelection = 0; float fTransAmount = 0.0; float fBalance = 100.25;
#include <stdio.h> int main(void) { const float INCHES_PER_FEET = 12; float height; char name[40]; printf("What is your name?: ");
用双引号将其打印将其打印在20个字符宽的字段中,整个字段用引号括起,名称在字段的右端。在20字符宽的字段的左端打印它,整个字段用引号括起来。将其打印在比名称宽三个字符的字段中。
#include <stdio.h> int main(void) {// printf("a a\\n"); printf("a \\n a \\n");
#include <stdio.h> int main(void) { int ageyears;/* age in years */ int agedays;/* age in days*/ //fromwww .yi ib ai .co m
#include <stdio.h> void functionA(void); void functionB(void); int main(void){ functionA();/*fromwww.yi i bai.com*/
#include <stdio.h> void my_function(void);/* C function prototyping */ int main(void){ printf("main.\\n");