#include<stdio.h>
#include<conio.h>
#include<string.h>
struct student
{
    int*ptr[23];
    char*name[12];//store address of character string

}s1;
void main()
{
    int roll=20;
    //char n='s';
    s1.ptr=&roll;//ERROR
    s1.name="zahid ali";//ERROR
    printf("roll no of student :%d\n",*s1.ptr);
    printf("name of student:%s\n",s1.name);
    getch();
}//plase coorect this error

Your struct members are arrays of pointers, but you're treating them as if they were just pointers.

Note that you can't assign to arrays and even if you could the values that you're trying to assign them are plain pointers, not arrays of pointers.

IE, what sepp2k said. IE:

    #include <stdio.h>
    #include<string.h>
    struct student
    {
        int* ptr[23];
        char* name[12];//store address of character string
    }s1;
    int main(void)
    {
        int roll=20;
        s1.ptr[0]=&roll;//ERROR
        s1.name[0]="zahid ali";//ERROR
        printf("roll no of student :%d\n",s1.ptr[0]);
        printf("name of student:%s\n",s1.name[0]);
        getch();
        return 0;
    }

I guess this should help.

    #include <stdio.h>
    #include<string.h>
    struct student
    {
    int* ptr[23];
    char* name[12];//store address of character string
    }s1;
    int main(void)
    {
    int roll=20;
    s1.ptr[0]=&roll;
    s1.name[0]="zahid ali";
    printf("roll no of student :%d\n",*(s1.ptr[0]));
    printf("name of student:%s\n",s1.name[0]);
    return 0;
    }
This article has been dead for over six months. Start a new discussion instead.