首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

为啥只得到了一个字符

2013-07-08 
为什么只得到了一个字符#include iostream#include stdafx.h#include string.h#include errno.h#i

为什么只得到了一个字符



#include <iostream>
#include "stdafx.h"
#include <string.h>
#include <errno.h>
#include <conio.h>
#include <ctype.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <wchar.h>


int _tmain(int argc, char* argv[])

   char* qrText="http://www.test.org/index.htm";
   char* qrText2="";
    if (argc != 2)
    {
        printf("参数错误,文件名\n");
        exit(EXIT_FAILURE);
    }else{
       qrText2=argv[1];
    
      cout<<qrText<<endl;
      cout<<qrText2<<endl;
    }
return 0;
}


为什么生成test.exe后运行,参数2取得的值是一个字符?
比如:
   test.exe   "abcdefg"
输出的是:"a"   ,我想输出的是参数2(qrText2)的值: "abcdefg",而qrText输出的是所有字符"http://www.test.org/index.htm"   ,新手学C++,不解。
[解决办法]
_tmain 参数是宽字符, 把_tmain改成main
[解决办法]
宽字符使用wcout
[解决办法]
纯C++的代码练习最好不要用_tmain作为主函数,main()就好
[解决办法]
using gcc in linux, no such issue.
output:
http://www.test.org/index.htm
abcdefg

热点排行