Hello all!
I seem to be in a very inconvenient situation, code::blocks has always worked perfectly for me until I have attempted to run a program with the getline() function used in a structure. I tested the code on an online compiler and the code worked perfectly. Source: cpp.sh/9roa
But when I compile the code I will post below as plain text my compiler does not report any bugs, just during runtime nothing is shown on the prompt then windows tells me the program crashed. I have attempted to fiddle around with the compiler settings, but I have had no luck.
Here is the code:
// code works on cpp.sh compiler, but fails to run on this compiler
#include <iostream>
#include <string>
using namespace std;
struct pizza
{
string compname;
int diameter;
int weight;
};
int main()
{
pizza pie = {pie.compname, pie.diameter, pie.weight};
cout << "Enter your pizza company's name:\n";
getline(cin, pie.compname);
cout << "Enter the pizza's diameter:\n";
cin >> pie.diameter;
cout << "Enter that mommas weight:\n";
cin >> pie.weight;
cout << "\n\n";
cout << "The pizza company's name is: " << pie.compname << "\n";
cout << "The pizza's diameter is: " << pie.diameter << "\n";
cout << "The pizzas weight is: " << pie.weight << "\n";
return 0;
}
If worse comes to worse, if one can recommend me another offline compiler like code::blocks, I would be happy.
Thanks for reading, Max