找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2305|回复: 0
收起左侧

字符串认识

[复制链接]
ID:51090 发表于 2014-9-17 14:36 | 显示全部楼层 |阅读模式


#include<stidio.h>

#define MSG "You must have many talents. Tell me something."
#define LIM 5
#define LINELEN 81

int main (void)
{
char name[LINELEN];
char talents[LINELEN];  //这两个为字符变量数组的定义,前面的const就是一种定义模式,放在这个位置与首位置意思一样,分号不可以少
int i;
const char m1[40] = "Limit yourself to one line's worth";
const char m2[ ] = "If you can't think of anything fake it";
const char *m3 = "\nEnough about me-what's your name?"; //指针的方法,这样写相当于首字母的地址被表示进行就可以了

const char *mytal[LIM] = {
        "Adding number swiftly",
        "Multiply accurately",
        "Stashing date",
        "Following instructions to the letter",
        "Understanding the C language",
        }; //与for语句的配合注意
printf ("Hi! I'm Clyde the Computer." "I have many talents");
printf ("Let me tell your some of them.\n");
puts ("What were they? Ah,yes,here's a partial list.");
for (i=0; i
  puts(mytal[i]);
puts(m3);  //输入
gets(name);  //输出
prinf ("Well,%s,%s\n",name, MSG);
printf ("%s\n%s\n",m1,m2);
gets(talents);
puts("Let's see if l've got that list:");
puts(talents);
printf("Thanks for the information.%s\n",name);
return 0;
}


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表