I am new to C++ and still learning it.I did an exercise on book and everything seems right in my program,but it will just crash when showing the inputs that I entered.I tried to ran it on different compilers and computers,the results were the same.Hope someone will help me thank you.And here is the program.
#include<iostream>
using namespace std;
int main()
{
string name;
char code[1];
float price;
int quantity;
cout<<"Enter an item name : "<<endl;
getline(cin,name);
cout<<"Enter the item code : "<<endl;
cin>>code;
cout<<"Enter the price per unit : "<<endl;
cin>>price;
cout<<"Enter the quanlity : "<<endl;
cin>>quantity;
cout<<"You entered the item name : "<<name<<endl
<<"You entered the item code : "<<code<<endl
<<"You entered the item price : "<<"RM"<<price<<endl
<<"You entered the item quantity: "<<quantity<<" unit"<<endl
<<"The total cost : "<<"RM"<<(quantity*price)<<endl;
return 0;
}
and this is the output: