Thread: CodeBlocks crashes

  1. #1
    Registered User
    Join Date
    Jan 2015
    Posts
    14

    CodeBlocks crashes

    Hello!

    I am trying to learn C++ with the help of "Jumping Into C++" book. Until now I´ve been quite successful. Problem is, if I try to define structure with string type fields, CodeBlocks crashes while I´m testing my program. As soon as I insert something that uses these string type fields, it´s over. I use GNU GCC Compiler.

    Some part of the code is in my native language. I hope this is not the problem for you.

    Code:
     
    #include <iostream>
    #include <string>
    
    
    using namespace std;
    
    
    struct isikuandmed
    {
    string taisnimi;
    int telnr;
    string aadress;
    };
    
    
    
    
    isikuandmed isik;
    
    
    isikuandmed uusisik()
    {
    isikuandmed isik1;
    isik1.taisnimi;
    isik1.telnr;
    isik1.aadress;
    
    
    return isik1;
    }
    
    
    isikuandmed sisestamine (isikuandmed isik)
    {
    cout<<"Telefoni number: \n";
    cin>>isik.telnr;
    cin.ignore();
    
    
    cout<<"Ees- ja perekonnanimi: \n";
    getline(cin,isik.taisnimi,'\n');
    
    
    
    
    cout<<"Aadress: \n";
    
    
    getline(cin,isik.aadress,'\n');
    
    
    
    
    }
    
    
    int valik ()
    {
    int valikunumber;
    cout<<"Kui soovid sisestada uue isiku andmeid, vajuta "<<'"'<<'1'<<'"'<<"\n\n";
    cout<<"Kui soovid sisestatud andmeid vaadata, vajuta "<<'"'<<'2'<<'"'<<"\n\n";
    cin>>valikunumber;
    if (valikunumber==1)
    {
    cout<<"\nTaida valjad\n\n";
    }
    
    
    }
    
    
    int main()
    {
    isik=uusisik ();
    valik ();
    sisestamine(isik);
    
    
    }
    What could be wrong?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    The build log; you need to read it and fix the problems it list!

    FYI: Using an undefined varible results in undefined things happing!!

    Code:
    -------------- Build: Release in crash (compiler: GNU GCC Compiler)---------------
    
    mingw32-g++.exe -Wall -fexceptions -O2  -c C:\test\crash\main.cpp -o obj\Release\main.o
    C:\test\crash\main.cpp: In function 'isikuandmed uusisik()':
    C:\test\crash\main.cpp:24:15: warning: statement has no effect [-Wunused-value]
    C:\test\crash\main.cpp:25:12: warning: statement has no effect [-Wunused-value]
    C:\test\crash\main.cpp:26:14: warning: statement has no effect [-Wunused-value]
    C:\test\crash\main.cpp: In function 'isikuandmed sisestamine(isikuandmed)':
    C:\test\crash\main.cpp:54:1: warning: no return statement in function returning non-void [-Wreturn-type]
    C:\test\crash\main.cpp: In function 'int valik()':
    C:\test\crash\main.cpp:69:1: warning: no return statement in function returning non-void [-Wreturn-type]
    mingw32-g++.exe  -o bin\Release\crash.exe obj\Release\main.o  -s  
    Output file is bin\Release\crash.exe with size 468.50 KB
    Process terminated with status 0 (0 minute(s), 0 second(s))
    0 error(s), 5 warning(s) (0 minute(s), 0 second(s))
    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with codeblocks
    By SilverClif in forum Windows Programming
    Replies: 6
    Last Post: 05-24-2011, 05:12 AM
  2. Replies: 8
    Last Post: 05-20-2011, 04:22 AM
  3. using codeblocks
    By torquemada in forum Tech Board
    Replies: 7
    Last Post: 04-20-2011, 08:57 PM
  4. Codeblocks.
    By Kitt3n in forum C++ Programming
    Replies: 5
    Last Post: 05-16-2010, 01:50 PM
  5. Codeblocks crashes linux?
    By Shakti in forum Tech Board
    Replies: 1
    Last Post: 03-25-2009, 07:26 AM