N
nk
Hi,
I'm a newbie on this language. I would be very happy if you help me
about the following issue:
The code below, reads some names(strings), stores them, and stores the
addresses in the pointer array, and writes them out. But it fails and
exits the program. I guess that it's about initializing the array but i
couldn't find a way to make it ok.
--------------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <conio.h>
int main()
{
char *a[50];
int i, numb;
printf("How many entries would you like to make?\n");
scanf("%d", &numb);
printf("Enter the names please..\n");
for ( i = 0; i < numb; i++ ) {
scanf("%s", a);
}
for ( i = 0; i < numb; i++ ) {
printf("%s", a);
}
getch();
return 0;
}
I'm a newbie on this language. I would be very happy if you help me
about the following issue:
The code below, reads some names(strings), stores them, and stores the
addresses in the pointer array, and writes them out. But it fails and
exits the program. I guess that it's about initializing the array but i
couldn't find a way to make it ok.
--------------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <conio.h>
int main()
{
char *a[50];
int i, numb;
printf("How many entries would you like to make?\n");
scanf("%d", &numb);
printf("Enter the names please..\n");
for ( i = 0; i < numb; i++ ) {
scanf("%s", a);
}
for ( i = 0; i < numb; i++ ) {
printf("%s", a);
}
getch();
return 0;
}