#include <stdio.h>
void main()
{
char a[100];
for (int i=0;i<5;i++)
{
printf("Enter a name[%i]=",i);
gets(&a[i*20]);
}
for (i=0;i<5;i++)
printf("Name[%i]=%s\n",i,&a[i*20]);
getchar();
}
//here is another method using C++ will not compile in a C compiler
//but it is safer to use since it utilizes the C++ std::string class
//and thus the user can type any length names without the risk of overwriting
//memory
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
void main()
{
string a[5];
for (int i=0;i<5;i++)
{
printf("Enter a name[%i]=",i); cin >> a[i]; }
for (i=0;i<5;i++)
cout << "name[" << i << "]=" << a[i] << "\n"; getchar();
}