c++错误 C2664
inf.open(name);head=NULL;while(!inf.eof()){Fread=newFile;inf>>Fread->num>>Fread->ans>...
inf.open(name);
head=NULL;
while(!inf.eof())
{
Fread = new File;
inf>>Fread->num>>Fread->ans>>Fread->qew>>Fread->input>>Fread->line>>Fread->choice1>>Fread->choice2;
Fread->next=NULL;
if(head==NULL)
{
head=Fread;
last=Fread;
last->next=NULL;
}
else
{
last->next=Fread;
last=Fread;
last->next=NULL;
}
}
inf.close();
error C2664: 'void __thiscall std::basic_ifstream<char,struct std::char_traits<char> >::open(const char *,int)' : cannot convert parameter 1 from 'class std::basic_string<c
har,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
出现了新的问题error C2065: 'strncpy_s' : undeclared identifier
begin:for(Fread=head;Fread;Fread=Fread->next){
char input[10],choice1[10],choice2[10];
if(strcmp(num,Fread->num)==0){
cout<<Fread->ans<<endl<<Fread->qew<<endl<<Fread->input<<endl<<Fread->line<<endl;
cin.getline(input,10);
strncpy_s(choice1,10,Fread->choice1,(strlen(Fread->choice1)-strlen(strchr(Fread->choice1 ,':'))));
strncpy_s(choice2,10,Fread->choice2,(strlen(Fread->choice2)-strlen(strchr(Fread->choice2 ,':')))); 展开
head=NULL;
while(!inf.eof())
{
Fread = new File;
inf>>Fread->num>>Fread->ans>>Fread->qew>>Fread->input>>Fread->line>>Fread->choice1>>Fread->choice2;
Fread->next=NULL;
if(head==NULL)
{
head=Fread;
last=Fread;
last->next=NULL;
}
else
{
last->next=Fread;
last=Fread;
last->next=NULL;
}
}
inf.close();
error C2664: 'void __thiscall std::basic_ifstream<char,struct std::char_traits<char> >::open(const char *,int)' : cannot convert parameter 1 from 'class std::basic_string<c
har,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
出现了新的问题error C2065: 'strncpy_s' : undeclared identifier
begin:for(Fread=head;Fread;Fread=Fread->next){
char input[10],choice1[10],choice2[10];
if(strcmp(num,Fread->num)==0){
cout<<Fread->ans<<endl<<Fread->qew<<endl<<Fread->input<<endl<<Fread->line<<endl;
cin.getline(input,10);
strncpy_s(choice1,10,Fread->choice1,(strlen(Fread->choice1)-strlen(strchr(Fread->choice1 ,':'))));
strncpy_s(choice2,10,Fread->choice2,(strlen(Fread->choice2)-strlen(strchr(Fread->choice2 ,':')))); 展开
3个回答
展开全部
inf.open(name); name是什么 大概这里搓了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询