我有一个计划:C++,命令行参数没有被正确解析
int _tmain(int argc, char* argv[])
{
std::cout << "STARTING" << std::endl;
std::cout << "Num inputs: " << argc << std::endl;
for(int i = 0; i < argc; i++)
std::cout << argv[i] << std::endl;
,我希望打印出所有的命令行参数。但是,输出是这样的:
./Test.exe的hello world
STARTING 民输入:3 。 ^ h W¯¯
看来,它只是看着每个参数的第一个字符,而不是整个的char *,直到终止符。
任何人有任何想法?
其他注意事项:通过VS2008创建它,我基本上是在互联网上复制和粘贴一个应该工作的例子。我已经在bash,powershell和cmd中运行该程序。
I beleive`_tmain()`expect`tchar` – ruslik 2010-12-07 21:10:47
如果你在你的程序中加入了一个`main`函数,它还会发生吗? IE浏览器,您更改`_tmain`的名称后... – 2010-12-07 21:11:15
相关:[http://stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c] (http://stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c) – 2013-09-02 08:35:53