我有一個計劃: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