听别人说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:if test="${not empty dataValue}">
fm.SAMPLING_DATE.value=" <c:out value='${dataValue.SAMPLING_DATE}'/ ......
#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 primer ......