Author Topic: Output not working like it should  (Read 496 times)

Offline kmuldrow

  • Single posting newcomer
  • *
  • Posts: 4
Output not working like it should
« on: September 18, 2019, 11:10:45 pm »
I am using CodeBlocks to teach C++ at a community college. We are using Windows PCs with Windows 10 installed.

Recently I tried to run the following program in class:

#include <iostream>
#include <string>
using namespace std;

int main()
{
    //int x;
    string name;
    double weight;

    cout << "Enter the first and last name: ";
    getline(cin, name);

    cout << "Enter the weight: ";
    cin >> weight;

    if (weight >= 105.0 && weight <= 141.0) {
        cout << name << " is in one of these weight classes: " << endl;
        cout << "Featherweight, Flyweight" << endl;
        cout << "Bantamweight, Lightweight" << endl;
    }
    else {
        cout << name << " is in one of these weight classes: " << endl;
        cout << "Light Welterweight, Welterweight, Middleweight, Light Heavyweight, Heavyweight" << endl;
    }

    return 0;
}

But when I ran the program, all the showed up in the console window was what you see in the attached file. I did not get the prompt and no output displayed. The code compiled with no errors.

The funny thing is, this program was working earlier until I put three or more cout's in either the if or the else. Also sometimes when I would compile successfully and the run the program, a dialog box would appear saying it appeared the program had not been built and asking if I would like to build it now.

This also happened to many students in my class. It was very frustrating to have this happen randomly and not know why.

Can anyone help me figure out why this happened? I hope I've given enough details on this...

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline kmuldrow

  • Single posting newcomer
  • *
  • Posts: 4
Re: Output not working like it should
« Reply #2 on: September 18, 2019, 11:37:44 pm »
How?

The only option I found was to have the full command log saved to an HTML file. I guess I'll attach that and see if that works.

UPDATE: It doesn't work. This forum won't allow me to upload an HTML file. I've taken a screen shot using the Snipping Tool and have attached that. Please let me know if this is what you mean.




Offline kmuldrow

  • Single posting newcomer
  • *
  • Posts: 4
Re: Output not working like it should
« Reply #3 on: September 18, 2019, 11:39:16 pm »
By the way, I am using CodeBlocks version 17.12 on Windows 10 and the mingw32-g++ compiler.

Offline kmuldrow

  • Single posting newcomer
  • *
  • Posts: 4
Re: Output not working like it should
« Reply #4 on: September 19, 2019, 12:53:38 am »
OK, I talked to an IT guy at our community college and he is certain the problem is because we had new anti-virus software (Cylance) installed on the lab computers last weekend.

I checked the logs for Cylance and, sure enough, it is quarantining every .exe file from a CodeBlocks project.

I guess it's on the Cylance people to figure out how to fix this. I was told a possible workaround was to create a folder named Compile on the Desktop, create projects within that folder, and they should run...but they didn't. Those executable files still got quarantined.  >:(

We'll try to get this worked out. Thanks for replying!!!

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2546
Re: Output not working like it should
« Reply #5 on: September 19, 2019, 09:33:28 am »
You can simply select the text in the output window and hit ctrl+c or right mouse -> copy and paste the log here in code tags (as described exactly and extensively in the link).

A compiler is a program that generates a other program, normally this is only done by viruses so nearly ever anti virus with heuristics as detection method detects a compiler as a virus that wants to replicate itself...