Hi everyone,
I am not getting how to enter values to that array. Please some one give me a solution.

typedef struct user {
      int array[10];
}user;

void main()
{
    int i;

user *tmp;

printf("enter array values");

for(i=0;i<10;i++)
{
    scanf("%d",&tmp->array[i]);
}   


for(i=0;i<10;i++)
{
  printf("[%d]\n",tmp->array[i]);

}
}

Recommended Answers

All 2 Replies

tmp first needs to point something:

user init;
user *tmp = &init;

Why not declare user temp; (no pointer) and change the references of the pointer -> to . as:
user temp;
...
&(tmp.array)

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.