having problems with output using pointers
void main()
{
int people,
i,j;
char *name[21],
**n_ptr=name;
printf("\nEnter the number of people > "
scanf("%d",&people);
for(i=0;i<people;i++)
strcpy(*n_ptr,NULL);
is this required?
for(i=0;i<num_students;i++)
{
printf("\nEnter Names for person %d ",i+1);
fflush(stdin);
gets(*n_ptr); //if I put the puts(*n_ptr here
**n_ptr++; // it works (but thats not what I
} //want)
for(j=0;*name;j++) //loop till null char is reached
{
printf("\n"
puts(*n_ptr++); //This is where the program crashes
} //It compiles alright though
}
I have tried several combinations but no joy
void main()
{
int people,
i,j;
char *name[21],
**n_ptr=name;
printf("\nEnter the number of people > "
scanf("%d",&people);
for(i=0;i<people;i++)
strcpy(*n_ptr,NULL);
is this required?
for(i=0;i<num_students;i++)
{
printf("\nEnter Names for person %d ",i+1);
fflush(stdin);
gets(*n_ptr); //if I put the puts(*n_ptr here
**n_ptr++; // it works (but thats not what I
} //want)
for(j=0;*name;j++) //loop till null char is reached
{
printf("\n"
puts(*n_ptr++); //This is where the program crashes
} //It compiles alright though
}
I have tried several combinations but no joy