c - accessing the array inside array of structures -


i have structure follows

struct {     char* ap;     char* inputs[10];     int e; }; 

then have created array of structure struct list [100];

now want fille array inputs[10] , using syntax access first location :

    ip=0;     inp=0;     list[ip].inputs[inp] 

but gettin error "error c2107: illegal index, indirection not allowed" on compiling code

please suggest how access array location inside array of structure.

regards priya  

here use array of character pointer in structure. allocate memory structure creation list of 100. think didn't create memory array of character pointer. have create memory each of character pointer. suggest example code.

#include <stdio.h>  struct { char* ap; char* inputs[10]; int e; };  int main() {     int ip=0;     int inp=0;     struct list[100];     list[ip].inputs[inp]= (char*)malloc(25);     scanf("%s",list[ip].inputs[inp]);//or other copy function fill string     printf("output %s",list[ip].inputs[inp]); } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -