我有一个非常简单的程序。
#include <stdio.h>
#include <string>
using namespace std;
struct scholar{
int number;
string fam;
int ocen;
};
int main(){
int len;
printf("vvedite n");
scanf("%d", &len);
scholar *barr= new scholar[len];
for(int i=0; i<len; i++){
printf("Nomer studenta ");
scanf("%d", &barr[i].number);
printf("\nFamilia ");
scanf("%s", barr[i].fam);
printf("\nOcenka");
scanf("%d", &barr[i].ocen);
}
delete [] bar;
但是在网上,我想输入family的地方,有一个警告:
warning: format specifies type 'char *' but the argument has type 'string'
(aka 'basic_string<char>') [-Wformat].
任何建议如何解决它?