[問題] _tmain 和 main 中的 Command Line Arg
看板C_and_CPP (C/C++)作者pinglunliao (王者:一條孤獨的不歸路)時間16年前 (2009/07/12 20:56)推噓2(2推 0噓 7→)留言9則, 4人參與討論串1/1
IDE環境:VS2008 C++ Express
int main( int argc, _TCHAR *argv[])
{
int count;
// Display each command-line argument.
for( count = 0; count < argc; count++ )
{
printf("%s\n", argv[count]);
}
}
若上述的程式碼產生的執行檔為 Test.exe
當我在 Visual Studio 2008 Command Prompt 下 Test.exe Test1 test2
執行的結果為
Test.exe
Test1
test2
int _tmain( int argc, _TCHAR *argv[])
{
int count;
// Display each command-line argument.
for( count = 0; count < argc; count++ )
{
printf("%s\n", argv[count]);
}
}
若上述的程式碼產生的執行檔為 Test.exe
當我在 Visual Studio 2008 Command Prompt 下 Test.exe Test1 test2
執行的結果為
T
T
t
我的疑問是為什麼在 _tmain 裡,
程式執行的結果會只輸出 Command Line Argument 的第一個字元,
而不是整個 Argument 的字串名稱?
--
http://blog.pixnet.net/pinglunliao Something About Game Programming
http://www.wretch.cc/blog/pinglunliao 白爛文
http://pinglunliao.spaces.live.com/ 新的希望
http://blog.roodo.com/pinglunliao
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.224.200.127
推
07/12 21:02, , 1F
07/12 21:02, 1F
→
07/12 21:03, , 2F
07/12 21:03, 2F
推
07/12 21:50, , 3F
07/12 21:50, 3F
→
07/12 21:50, , 4F
07/12 21:50, 4F
→
07/12 21:51, , 5F
07/12 21:51, 5F
→
07/12 23:47, , 6F
07/12 23:47, 6F
→
07/12 23:48, , 7F
07/12 23:48, 7F
→
07/12 23:49, , 8F
07/12 23:49, 8F
→
07/12 23:49, , 9F
07/12 23:49, 9F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章