您好我想从C此函数提示输入名字和姓氏的用户,并在输出中指标的影响返回第一个和最后一个名称转换转换C函数代码C++类的方法
//the C codes is this:
void getPatronName(char *fn, char *ln) {
printf("\n Enter patron name ([first] [last]): ");
scanf("%s %s", fn, ln);
}
//will it be equivalent to doing this in C++? :
void MenUI::getPatronName(string *fn, string *ln) {
cout<<endl<<" Enter patron name ([first] [last]): ";
cin>>*fn>>*ln;
}
谢谢,
代码是否工作?问题是什么? – 2014-09-29 03:51:43
为什么浪费时间将不安全的C代码转换为不安全的C++代码?摆脱指针。 – PaulMcKenzie 2014-09-29 04:03:52
是的,它会以类似的方式工作。但是你的'问题'是什么? – 2014-09-29 04:11:44