News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

cout not working in codeblocks

Started by cbusername, February 21, 2013, 02:31:45 PM

Previous topic - Next topic

cbusername

default program is not working. It shows no error, but does not output.
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello World!" << endl;
    return 0;
}

jarod42

Do you check the 'pause when execution ends' in build target options ?

cbusername

In build options there is no 'pause when execution end' option. that is 'build option' in global compiler settings. Still not working.

cbusername

My apologies. I found build target option and 'pause when execution ends' was checked.
I unchecked it and tried, but I am getting the same problem.

jarod42

Right-click on your project, click 'Properties...'
click on the 'Build target' tab
check that the checkbox 'pause when execution ends' is checked for each build target (Debug/Release).

What does happen if you launch your executable from cmd line ?

cbusername

'Pause when execution ends' is checked for both debug and release. Program is not running from cmd line. I tried Program1 (which is the name of the project) from the directory where it is and it says access denied.

jarod42

Where is the exe ? is it a special directory ?
Which permission has the exe ? (if on *nix, which is your umask value ?)...

cbusername

it is in c:users/orindombanerjee/desktop/bin/debug

orindom banerjee is my name.

cbusername

c:\users\orindombanerjee\desktop\bin\debug

no special directory. It stored it there by default.

jarod42

I would says that Desktop is a special directory...

- Try to copy and run your exe from another directory (Or change output directory in C::B)
- Check if you can run an other executable in the "problematic" directory.
- Look at Software Restriction Policy (SRP) in the user's Group Policy Object (GPO) if something blocks it.

So it is not a C::B issue, but your OS which forbids to launch your exe....

cbusername

#10
it doesn't work from c:\ either, where i copied it. It still says access denied after long pause
there's no other program i know as i am just begining
i know nothing about SRP and GPO, need guidance

It might not be my os issue as devc++ is working fine.

stahta01

#11
Quote from: cbusername on February 23, 2013, 06:29:05 AM
it doesn't work from c:\ either, where i copied it. It still says access denied after long pause
there's no other program i know as i am just begining
i know nothing about SRP and GPO, need guidance

It might not be my os issue as devc++ is working fine.

WARNING: The root drive (C:\) is a Special Folders in Windows 7!!

I suggest trying "c:\users\orindombanerjee" and make sure your anti-virus software is not the issue.

Also read the FAQs at least this one http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

cbusername

hi,
I had the same problem but then when that got solved this doesn't work:
#include <iostream>

using namespace std;

int main()
{
    int tag = 9;
    cout << tag;

    return 0;
}

but this works:
#include <iostream>

using namespace std;

int main()
{
    int tag = 9;
    cout << "value" << tag;

    return 0;
}

How bizaare! Can someone please help. I am not able to progress as I need codeblocks for c++. Its working fine in devc++.

Alpha

When posting code, please use [code][/code] tags.

Both code snippets you provided work as expected for me.  However, as I am unsure what you mean by "doesn't work", I cannot further diagnose.
(Also, have you gone through everything in the FAQ entry posted by stahta01?)

Jenna

Compiler- and programerrors related question violate our forum rules.

Topic locked !