Issue with cout in ROOT: Program exits without displaying output

So I recently installed ROOT on my Ubuntu 16.04 LTS computer. However, I have several programs which are supposed to cout data to the terminal that refuse to do this. Strangely enough these programs don’t display any errors. They just won’t display the data I need. I am including two examples here. The first example runs with no errors and displays data to the terminal. The second program fails to display the appropriate data. If anyone has had an issue like this before or knows what might be going on I would appreciate the input. Please forgive any errors or forum etiquette as I am a brand new poster.

Example 1(works perfectly):

//#include <iostream>
//#include <fstream>
//#include <string>
//#include <sstream>
//using namespace std;
//
//void Medians(){
//  double B[531111];
//    for (int i=0;i<531111;i++){
//      cout<<B[i]<<endl;
//    }
//}

Example 2(Runs but doesn’t display output):

//#include <iostream>
//#include <fstream>
//#include <string>
//#include <sstream>
//using namespace std;
//
//void Medians(){
//  double A[531111];
//  double B[531111];
//    for (int i=0;i<531111;i++){
//      cout<<A[i]<<endl;
//    cout<<B[i]<<endl;
//    }
//}

This post system apparently doesn’t do indents so let me assure you that the indents are correct. Thank you.

If it is the actual code - then both should be ok, since they are both commented out. If it is not - please show the real code, not this … hmmm. snippet.

Hi,

welcome to root.
Three things:

  1. This is the ROOT forum and your programs do not use ROOT. Please refer to C++ fora in the future.
  2. Have a look to the original post. You will see how display code in posts.
  3. As timur says, if the comments are there, nothing will happen, but this maybe you know. The memory is uninitialised, I wonder what you are trying to achieve with the code above. Try:
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;

void Medians(){
  double A[531111];
  double B[531111];
    for (int i=0;i<531111;i++){
      cout<< "A " << A[i]<<endl;
      cout<< "B" << B[i]<<endl;
    }
}

@tpochep: Unfortunately this code is only an example. I had to comment it out for this post because the include statements were getting blown up by the software used to post here. I have a much longer code which involves root but I created these two examples to make it simpler to read.

@Danilo: Thanks for the input! However, when I run the code you suggested the result is the same. The code runs to completion and automatically exits root without displaying any information other than the root intro and: “Processing Medians.cpp…” Thank you.

https://root-forum.cern.ch/t/no-error-when-macro-crashes/14931
https://root-forum.cern.ch/t/upper-limit-of-entries-in-one-bin-and-in-whole-histogram/15475
https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971
https://root-forum.cern.ch/t/issue-3d-histogram/16012
https://root-forum.cern.ch/t/std-bad-alloc/14432

@Wile_E_Coyote: Thank you so much! It was my soft stack size! I reset it and everything runs now. Thank you to everyone who helped.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.