2013-06-19 59 views
0

我想将字符串数组传递给像这样的函数int function (string text[])。但智能感知说标识符字符串是未定义的。为什么我不能像通常用int数组那样传递字符串数组?将字符串数组传递给函数C++

+1

_IntelliSense_对于你的代码是否工作并不是一个明确的说法,如果你编译它会发生什么? –

+0

你有'#include '和'使用std :: string'吗? – Mankarse

+0

因为'int'是一个内置的数据类型,而'string'是一个使用内置类型创建并通过标准库公开的数据类型。 – legends2k

回答

2

您使用std::string还是仅仅使用string?如果您的代码中没有它,请尝试添加using std::string

+0

我写过使用namespace std; – Sam379

+3

'#include '怎么办? – austin

+0

@ Sam379不要'使用命名空间std',看看为什么[这里](http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice)。 – syb0rg