User forums > Using Code::Blocks

"Program tested to work crashes on me during run time on Code::Blocks compiler"

(1/1)

max2343255345:
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

stahta01:
Please read the rules for this site.
http://forums.codeblocks.org/index.php/topic,9996.0.html

http://wiki.codeblocks.org/index.php/FAQ-General#Q:_What_Code::Blocks_is_not.3F

Tim S.

BlueHazzard:

https://www.youtube.com/results?search_query=debug+a+crash+in+codeblocks

wtf do you expect to happen in this line???

--- Code: ---pizza pie = {pie.compname, pie.diameter, pie.weight};
--- End code ---

note: i won't answer any c/c++ related question future, because it is against the rules of this forum...

greetings

Navigation

[0] Message Index

Go to full version