my getline isn't working can someone help
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <iostream>
#include <string>
using namespace std;
struct StockInfo
{
string coname;
int numShares;
int PurPrice;
int CurrPrice;
};
int main()
{
const int size=10;
int i;
StockInfo portfolio[size];
{
for(i=0;i<10;i++)
cout << "enter company's name please:"<<endl;
getline(cin,portfolio[i].coname);
cout << "enter the number of shares bought:"<<endl;
cin >> portfolio[i].numShares;
cout <<"What was the purchase price?"<<endl;
cin >> portfolio[i].PurPrice;
cout << "what is the current price of the share?"<<endl;
cin >> portfolio[i].CurrPrice;
cin.ignore();
}
return 0;
}.
|
output
enter company's name please:
enter company's name please:
enter company's name please:
enter company's name please:
enter company's name please:
enter company's name please:
enter company's name please:
enter company's name please:
enter company's name please:
enter company's name please:
Segmentation fault (core dumped)
------------------
(program exited with code: 139)
Press return to continue