永发信息网

C++ 定义字符串数组报错(C2373)!

答案:2  悬赏:10  手机版
解决时间 2021-12-25 12:12
  • 提问者网友:练爱
  • 2021-12-25 00:04
报错信息如下:
--------------------Configuration: LS - Win32 Debug--------------------
Compiling...
LS.CPP
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\LS.CPP(44) : error C2373: 'read_username' : redefinition; different type modifiers
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\LS.CPP(40) : see declaration of 'read_username'
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\LS.CPP(45) : error C2373: 'read_password' : redefinition; different type modifiers
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\LS.CPP(41) : see declaration of 'read_password'
执行 cl.exe 时出错.

LS.OBJ - 1 error(s), 0 warning(s)

我定义了两个字符串数组:
char read_username[13];
char read_password[6];
然后加了个输入语句:
std::cin>>read_username;
进行比较时是这么比较的:
strcmp(数组1,数组2)

应该没错啊!为什么会报错?
由于总体代码太长,就不发了

为什么我用下述函数进去时用户名和密码输什么都行啊:
void save_username()
{
ofstream in;
in.open("用户名.txt",ios::trunc);
in< in.close();
cout<<"The username was saved successfully!"<}

void read_username()
{
fstream out;
out.open("用户名.txt",ios::in);
out.getline(read_username_verb,13,'\n');
out.close();
}
最佳答案
  • 五星知识达人网友:duile
  • 2021-12-25 01:32
应该是重复定义,你把这两个数组名改了试试
全部回答
  • 1楼网友:撞了怀
  • 2021-12-25 02:57
你好! 楼上正解 redefinition .....显然 重复定义标识符 仅代表个人观点,不喜勿喷,谢谢。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯