Author Topic: Codeblocks output window error / shut-down?  (Read 18132 times)

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Codeblocks output window error / shut-down?
« on: November 17, 2013, 12:44:20 pm »
If I go to the .exe file generated via code::blocks and run my program it runs fine and works properly too.
If I run the program via code::blocks output window I get an error and the program shuts down.

I could paste the code below, but I'm not sure if that is the issue.  Checking that elsewhere.  I thought I would keep this question purely code::blocks related. 

Is there a setting in Code::blocks which would cause this? 

As I said, the program runs find, but if I hit Run at the top of the IDE I get an error.

Thanks

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Codeblocks output window error / shut-down?
« Reply #1 on: November 17, 2013, 01:08:08 pm »
We have a significant lack of crystal balls here, so without information we can't help sorry....

greetings

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codeblocks output window error / shut-down?
« Reply #2 on: November 17, 2013, 01:12:43 pm »
Ok.  Well, hopefully some code helps.  I thought there might be a setting in the codeblocks IDE which may cause this.  Who's to say?


Code
#include <iostream>
#include <cstdlib>
#include <vector>
#include <fstream>
#include <sstream>


using namespace std;

int main()
{

ifstream myfile;
string mystring;
vector<int> vect;

myfile.open("test.txt",ios::out |ios::binary);
myfile >> noskipws;
getline(myfile,mystring);

stringstream ss(mystring);



int i;
while (ss >> i)
{
    vect.push_back(i);
    if (ss.peek() == ',')
        ss.ignore();
}


for (int x  = 0; x < vect.size(); x++) //Now display the vector contents.
    cout << vect[x] << endl;


  system("pause>nul");
}

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Codeblocks output window error / shut-down?
« Reply #3 on: November 17, 2013, 01:58:57 pm »
the error would help much more...

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codeblocks output window error / shut-down?
« Reply #4 on: November 17, 2013, 02:20:15 pm »
Actually, the error has gone now.  I restarted my pc.    The error was, this program 'program name' has encountered an error and needs to shut down.  It's a windows error screen.  (ask if you want to send the error to microsoft.

The problem is that there is no output in the output window.  I have to double click on the exe file to see the output. 

Is that something to do with code::block settings.

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codeblocks output window error / shut-down?
« Reply #5 on: November 17, 2013, 02:26:32 pm »
False alarm all.. False alarm.. Please carry on with your day.

The problem was that I didn't have the text file in the root directory of the project.  I had it in with the binary file which is why it would only work when I executed the binary directly.

Such as simple problem.  One of which I'm sure I've solved more than once. 

Round we go...