积极答复者
命令行程序每次只打印第一个字符?

问题
-
费解啊,现在的问题是,主函数是
int _tmain(int argc, char* argv[], char* envp[]);
通过
printf("%s\n\n",argv[1]);
打印发现,为什么每次只打印第一个字符?
比如输入
test.exe 564 56 6
它仅仅输出 5
??????
好像没有问题吧?
环境是win 7 的cmd,管理员运行也不好使。
发现在XP能通过cmd传入参数的程序,在win7 cmd 下也失效。
- 已编辑 physics_fqh 2010年6月8日 13:58 补充
- 已编辑 Sheng Jiang 蒋晟Moderator 2010年6月8日 14:17 标题含糊
答案
-
int wmain(int argc, wchar_t *argv[])
{
for (int i = 0; i < argc; i++)
{
wprintf(L"%s\n", argv[i]);
}return 0;
}
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 physics_fqh 2010年6月9日 2:13
全部回复
-
int wmain(int argc, wchar_t *argv[])
{
for (int i = 0; i < argc; i++)
{
wprintf(L"%s\n", argv[i]);
}return 0;
}
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 physics_fqh 2010年6月9日 2:13