听别人说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写的DLL文件C、PB能调用VB不能调用?
VB里为什么有的DLL直接通过引用可以使用?有的需要通过declare申明外部函数?这些DLL有什么差别?
1、为什么PB能通过DECLARE声明而VB不行?
2、如果这个dll中的 ......
#include <stdio.h>
#include <graphics.h>
void main()
{
int x0,y0,x1,y1,driver,mode,i;
driver=VGA;
mode=VGAHI;
initgraph(&driver,&mode,&qu ......
问一下:
#include <stdio.h>
int main()
{
char x, y, z;
int i;
int a[16];
for(i=0; i<=16; i++)
{
a[i] = 0;
......
6月5日消息,XX网站日前评出了10项大势已去的计算机技术。其中,有些技术已经被淘汰,有些即将被淘汰。如著名的Cobol语言,以及IBM的OS/2系统。
以下为XX网站评出的被淘汰的10项计算机技术:
......
现在谭浩强的C语言已经快学忘了,但都是很基础的东西感觉,不能干什么,要想再提升接下来干点啥好
编点小工具,再学数据结构
看看课后习题
如果学c的话,看《the c programming language》,是c语言的 ......