编译时出现错误:预期的)和(在c中用于以下程序:
#include<stdio.h>
#include<conio.h>
struct student
{
char name[20];
int rollno;
int age;
char classes[10];
};
void printdata(struct student &sob); //getting error in this line
void main()
{
struct student stud;
clrscr();
printf("enter student details:");
printf("\nenter student name:"); fflush(stdin);
gets(stud.name);
printf("\nenter age:");
scanf("%d",&stud.age);
printf("\nenter rollno:");
scanf("%d",&stud.rollno);
printf("\nenter class of student:"); fflush(stdin);
gets(stud.claases);
printdata( &stud);
getch();
}
void printdata(struct student &sob) //getting error in this line
{
struct student *ptr;
ptr=sob;
printf("student details are as follows:");
printf("\nstudent's name:"); fflush(stdout);
puts(ptr->name);
printf("\n student' age:%d",ptr->age);
printf("\n student's roll no:%d",ptr->rollno);
printf("\n student's class:"); fflush(stdout);
puts(ptr->classes);
}
是我已经声明了结构学生,那么为什么它在两行中给我错误(和)..