I just made this program but it doesn't work the way I want.
[B]#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
int a;
cout << "How many names?:";
cin >> a;
char name [a][10];
int ra[a];
for (int i=0;i<a;i++){
cout << "name"<<i<<"?:";
cin.getline (name [i],10);
}
for (int i=0;i<a;i++){
ra[i]=rand() %100+1;
}
for (int i=0;i<a;i++){
cout << name[i] << ":" << ra[i] << "\n"
}
cin >> ra[1];
}
[/B]
The problem is that if I execute the code I can't enter name0 it seems to jump directly to name 1.Can anybody help with this?


Sign In
Create Account

Back to top










