User forums > Using Code::Blocks

Application with list (accessing the items with iterator) is crashing.

(1/2) > >>

srinu4007:
Application crashes with below pop-up message while performing "Build and Run" operation. Please find the source code below.

"A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available".


Got below error message on the command prompt when i clicked OK button on the pop-up box.

" Process returned 255 (0xFF)   execution time : 703.988 s
Press any key to continue. "

On clicking enter on the command prompt .... getting below message in "Build log" tab of Code::Blocks application.

-------------- Run: Debug in Example_1 (compiler: Borland C++ Compiler (5.5, 5.82))---------------

Checking for existence: F:\Softwares\Documents\L_C & CPP\Examples\Example_1\bin\Debug\Example_1.exe
Executing: "F:\Softwares\SWs Installed\CodeBlocks/cb_console_runner.exe" "F:\Softwares\Documents\L_C & CPP\Examples\Example_1\bin\Debug\Example_1.exe"  (in F:\Softwares\Documents\L_C & CPP\Examples\Example_1\.)
Process terminated with status 255 (16 minute(s), 21 second(s))


Source Code:
--------------------
#include <iostream>
#include <list>
#include <string>

using namespace std;

int main()
{
    list<string> names;
    names.push_back("Mary");
    names.push_back("Zach");
    names.push_back("Elizabeth");
    cout << "--- elements ---" << endl;

    list<string>::iterator iter = names.begin();
    while (iter != names.end())
    {
          cout << *iter << endl;
          ++iter;
    }

    return 0;
}



commented below line and ran the "Build and Run" operation. It ran successfully. Couldn't understand exactly what is the problem with below line.

          cout << *iter << endl;


Tried including below line also ... still issue is not resolved.

#include <windows.h>


Note: Using Code::Blocks 13.12 version with Borland C++ compiler is used to compile C++ programs on Windows 10 operating system.

oBFusCATed:
My guess is that your compiler is broken or doesn't work correctly on windows 10.

Please contact your compiler vendor for support.
We don't and cannot provide support for any of the compilers that can be used with codeblocks or are shipped with it!

srinu4007:
Thanks oBFusCATed.

But I am able to compile other applications like vector or list for that matter with out iterator code. I tried by adding try and catch as shown below. Expected a print message on command prompt, but it didn't work. Has this any thing to do with codeBlocks not properly integrated with compile, etc.,. ?

Source Code:
-----------------

#include <iostream>
#include <list>
#include <string>
#include <windows.h>
#include <stdexcept>

using namespace std;

int main()
{
    try {
        list<string> names;
        names.push_back("Mary");
        names.push_back("Zach");
        names.push_back("Elizabeth");
        cout << "--- elements ---" << endl;

        list<string>::iterator iter = names.begin();
        while (iter != names.end())
        {
            cout << *iter << endl;
            ++iter;
        }
    }
    catch (...)
    {
        cout << "Cought exception" << endl;
    }
    return 0;
}

oBFusCATed:
No idea, I've never used this compiler with codeblocks.

The only thing you can do is try to compile the same program on the command line and see if it works.
If it works we might be able to fix the cb integration of the compiler.
But don't count on it. We're not big fans of supporting ancient compilers running on latest oses.

srinu4007:
which compiler do you suggest for learning/practicing c/c++ on windows and unix os's ?

Navigation

[0] Message Index

[#] Next page

Go to full version