易截截图软件、单文件、免安装、纯绿色、仅160KB

新手提问:C有string吗?

听别人说C没有string类型,于是自己写了个例子测试一下,发现编译不通过。如果C没有string的话C是如何实现输出字符串的?
C/C++ code:
#include <stdio.h>
#include <string>

int main()
{
string str="abc";
}

C的串是用char *定义的,
C/C++ code:
#include <stdio.h>
#include <string.h>
int main()
{ char *str="abc"; }




C中没有字符串类型的,不过可以通过字符型数组来替代字符串类型。

没有。

char*,指针,直到最后一个单元为NULL。

具体可以看C标准库 <string.h>

char ch[3]="asd";
printf("%s\n",ch);

C/C++ code:
#include <stdio.h>
#include <string.h>

int main(void)
{
char *str;
str="abc";
printf("%s\n",str);

return 0;
}


引用
听别人说C没有string类型,于是自己写了个例子测试一下,发现编译不通过。如果C没有string的话C是如何实现输出字符串的?
C/C++ code#include <stdio.h>
#include <string>int main()
{string str="abc";
}


相关问答:

jsp中 <c:if test> 相关问题

在查询后将查询出来的值赋给各输入框
<c:if test="${not empty dataValue}">
      fm.SAMPLING_DATE.value=" <c:out value='${dataValue.SAMPLING_DATE}'/ ......

c基础

#include <string.h>
#include <stdio.h>

void main()
{
int i;
char buf[]="abcde";
strncpy(buf,"abc",3);
for(i=0;i <5;i++)
printf(&q ......

你们现在还在用C吗?C有前途吗?

你们现在还在用C吗?C有前途吗?
一定,并永远坚持

引用
一定,并永远坚持



有用。

楼主何出此言

楼主来c版问这个问题是踢馆用意吗哈哈

越来越冷是肯定的,完全淘汰倒也没那么容易

c ......

大家觉得 C Primer Plus 这本书怎么样呢?

用这本书入门怎么样呢  跟谭浩强的相比如何? 谢谢
我把这本看了几篇,确实很好的书。就不要拿它跟 谭 的书比了, 谭 的书要照顾全国读者。

不可同日而语

一个是国外的,一个是国内的

学完c primer ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号