OK so here it is:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
main()
{
char names[20] = "\0";
char * pNames = names;
char * pList[3] = {"\0", "\0", "\0"};
int i = 0;
for (i = 0; i < 3; i++)
{printf("Enter a name: \n");
scanf("%19s", pNames);
pList[i] = pNames;}
for (i = 0; i < 3; i++)
{printf("%s", pList[i]);}
return 0;
}
it outputs the last name entered 3 times. What am I doing wrong. the intention here is to input 3 names and then output them one after the other.
Thanks in advance for putting up with my noobish nature.









LinkBack URL
About LinkBacks



