只要我注释掉cin.get行,我的代码似乎在编译,但我不知道我是如何滥用它的。作为第二个问题,一旦我弄清楚我在那里做错了什么,我是否可以使用getlength计算该字符串的长度,然后使用prtintf将该长度的cstring打印到输出文件我是计划加入?我不允许使用字符串btw。
#include<iostream>
#include<fstream>
#include<cstring>
#include<string>
using namespace std;
struct thisType
{
char peiceOne[100];
char peiceTwo[100];
char peiceThree[100];
};
void requestData();
void storeData(char *charArray[]);
int main(){
thisType tempStruct[100];
requestData();
return 0;
}
void requestData(){
cout << endl << "Please enter data as follows, without brackets: [peiceOne];"
<< "[peiceTwo];[peiceThree] " << endl;
}
void storeData(char *tempStruct[100]){
//cin.get(tempStruct[0], 100, ";");
}
答案 0 :(得分:1)
在cin.get()
中,第三个参数应为char
,但您传递的是const char*
类型的字符串。
您应该将分隔符放在单引号中,以解决错误。