C语言中如何定义一个字符串和一个字符数组?

2024-11-22 13:35:11
推荐回答(3个)
回答(1):

  • 字符串:char *p="string";

  • 字符数组:char str[6] = {'s','t','r','i','n','g'};

回答(2):

C语言没有字符串类型,就是字符数组
char a[20]="hello";

回答(3):

string str;
char[32] strarry;

str="you are a goog man";
atrarry={'y','o','u',' ','a','r','e',' ','a',' ','g','o','o','d',' ','m','a','n'};