关于ubuntu和VS中编译C++的一点问题

来源:互联网 发布:怎样注册知乎账号 编辑:程序博客网 时间:2024/05/15 21:24

今天在Ubuntu中用g++编译下面这个程序的时候,一直保错说没有定义函数strcpy;

#include<iostream>

#include<string>

using namspace std;

int main()

{

char a[]="hello ubuntu";

char b[]="hello";

strcpy(a,b);

cout<<a<<endl;

return 0;

}

后来换成#include<string.h>就可以了,但是我在VS中编译这个程序没有任何问题哈,没怎么搞懂这个问题哈。而且在VS中只要用这两个里面的一个#include<string.h>,#include<string>就可以调用strcpy 函数。

是因为ubuntu中没有采用C++ 标准库么?我知道#include<string.h>,#include<string>是属于不同的头文件,但是我不太理解为什么VS中可以而Ubuntu中就不可以呢?

原创粉丝点击