易截截图软件、单文件、免安装、纯绿色、仅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";
}


相关问答:

为什么C写DLL文件C、PB能调用VB不能调用

为什么C写的DLL文件C、PB能调用VB不能调用?
VB里为什么有的DLL直接通过引用可以使用?有的需要通过declare申明外部函数?这些DLL有什么差别?

1、为什么PB能通过DECLARE声明而VB不行?
2、如果这个dll中的 ......

菜鸟求解:c图形问题

#include <stdio.h>
#include <graphics.h>
void main()
{
  int x0,y0,x1,y1,driver,mode,i;
  driver=VGA;
  mode=VGAHI;
  initgraph(&driver,&mode,&qu ......

C 程序问题 (二) - C/C++ / C语言

问一下:
#include <stdio.h>
int main()
{
  char x, y, z;
  int i;
  int a[16];
  for(i=0; i<=16; i++)
  {
  a[i] = 0;
  ......

我很伤心,C即将被淘汰!

6月5日消息,XX网站日前评出了10项大势已去的计算机技术。其中,有些技术已经被淘汰,有些即将被淘汰。如著名的Cobol语言,以及IBM的OS/2系统。

  以下为XX网站评出的被淘汰的10项计算机技术:

   ......

C学位你发基础该干啥?

  现在谭浩强的C语言已经快学忘了,但都是很基础的东西感觉,不能干什么,要想再提升接下来干点啥好
编点小工具,再学数据结构

看看课后习题

如果学c的话,看《the c programming language》,是c语言的 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号