#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

problem in 14 and 15 line.

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;
    }

sorry i am not geting why ur using the pointer to ptr

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;
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.