⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strings.c

📁 c primer plus 第五版 的源代码
💻 C
字号:
// strings.c -- stringing the user along
#include <stdio.h>
#define MSG "You must have many talents. Tell me some."
                          // a symbolic string constant
#define LIM  5
#define LINELEN 81        // maximum string length + 1
int main(void)
{
    char name[LINELEN];
    char talents[LINELEN];
    int i;
                          // initializing a dimensioned
                          // char array       
    const char m1[40] = "Limit yourself to one line's worth.";
                          // letting the compiler compute the
                          // array size     
    const char m2[] = "If you can't think of anything, fake it.";
                          // initializing a pointer  
    const char *m3 = "\nEnough about me -- what's your name?";
                          // initializing an array of
                          // string pointers         
    const char *mytal[LIM] = {  // array of 5 pointers
          "Adding numbers swiftly",
          "Multiplying accurately", "Stashing data",
          "Following instructions to the letter",
          "Understanding the C language"
          };

    printf("Hi! I'm Clyde the Computer."
           " I have many talents.\n");
    printf("Let me tell you some of them.\n");
    puts("What were they? Ah, yes, here's a partial list.");
    for (i = 0; i < LIM; i++)
        puts(mytal[i]);   // print list of computer talents
    puts(m3);
    gets(name);
    printf("Well, %s, %s\n", name, MSG);
    printf("%s\n%s\n", m1, m2);
    gets(talents);
    puts("Let's see if I've got that list:");
    puts(talents);
    printf("Thanks for the information, %s.\n", name);
  
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -