找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 2282|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

字符串認(rèn)識

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:51090 發(fā)表于 2014-9-17 14:36 | 只看該作者 回帖獎勵 |倒序?yàn)g覽 |閱讀模式


#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];  //這兩個為字符變量數(shù)組的定義,前面的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?"; //指針的方法,這樣寫相當(dāng)于首字母的地址被表示進(jìn)行就可以了

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;
}


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表