I am fairly new to C++ and mostly used VB up to this point.
I am trying to create a program that allows me to input multiple names into an array. Here is my code so far.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int friends[3];
int x=0;
for (x=0;x<3;x++)
{
cout << "Please enter the name of person " << x+1 << endl;
cin >> friends[x];
}
cout << friends[0];
system("pause");
return 0;
}
My problem is the first loop cycle takes the cin statement, but as soon as I hit return it shows lines 2 and 3 without taking any more input. I am probably missing something very obvious like run the loop x amount of times or take user input however many times the upper limit to the For loop.