I am a beginner in c++. In c this program works . But when run in C++ it gives
an error while assigning a pointer value to an integer variable.
n1 = *(&sdobj.mark1);
n2 = *(&sdobj.mark2);
The program is given below. Can anybody explain.
#include<stdio.h>
struct student
{
char *name[5][10];
int *mark1[5];
int *mark2[5];
}sdobj;
void main()
{
int n1, n2;
int total ;
for(i=0;i<5;i++)
{
printf("Name :"
scanf("%s",sdobj.name);
printf("Mark1:"
scanf("%d",&sdobj.mark1);
printf("Mark2:"
scanf("%d",&sdobj.mark2);
}
for (i=0;i<5;i++)
{
printf("\nName: %s\n",sdobj.name);
printf("Mark1 : %d\n",*(&sdobj.mark1));
printf("Mark2 : %d\n",*(&sdobj.mark2));
n1 = *(&sdobj.mark1);
n2 = *(&sdobj.mark2);
total = n1 + n2;
printf("Total : %d\n", total);
}
}
Thank U in advance