Author Topic: cout not working in codeblocks  (Read 27322 times)

Offline cbusername

  • Single posting newcomer
  • *
  • Posts: 8
cout not working in codeblocks
« on: February 21, 2013, 02:31:45 pm »
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;
}

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: cout not working in codeblocks
« Reply #1 on: February 21, 2013, 02:37:50 pm »
Do you check the 'pause when execution ends' in build target options ?

Offline cbusername

  • Single posting newcomer
  • *
  • Posts: 8
Re: cout not working in codeblocks
« Reply #2 on: February 21, 2013, 04:35:07 pm »
In build options there is no 'pause when execution end' option. that is 'build option' in global compiler settings. Still not working.

Offline cbusername

  • Single posting newcomer
  • *
  • Posts: 8
Re: cout not working in codeblocks
« Reply #3 on: February 21, 2013, 04:45:55 pm »
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.

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: cout not working in codeblocks
« Reply #4 on: February 21, 2013, 04:52:22 pm »
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 ?

Offline cbusername

  • Single posting newcomer
  • *
  • Posts: 8
Re: cout not working in codeblocks
« Reply #5 on: February 22, 2013, 08:39:11 am »
'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.

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: cout not working in codeblocks
« Reply #6 on: February 22, 2013, 10:32:16 am »
Where is the exe ? is it a special directory ?
Which permission has the exe ? (if on *nix, which is your umask value ?)...

Offline cbusername

  • Single posting newcomer
  • *
  • Posts: 8
Re: cout not working in codeblocks
« Reply #7 on: February 22, 2013, 02:34:25 pm »
it is in c:users/orindombanerjee/desktop/bin/debug

orindom banerjee is my name.

Offline cbusername

  • Single posting newcomer
  • *
  • Posts: 8
Re: cout not working in codeblocks
« Reply #8 on: February 22, 2013, 02:58:44 pm »
c:\users\orindombanerjee\desktop\bin\debug

no special directory. It stored it there by default.

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: cout not working in codeblocks
« Reply #9 on: February 22, 2013, 04:32:40 pm »
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....

Offline cbusername

  • Single posting newcomer
  • *
  • Posts: 8
Re: cout not working in codeblocks
« Reply #10 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.
« Last Edit: February 23, 2013, 06:31:12 am by cbusername »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: cout not working in codeblocks
« Reply #11 on: February 23, 2013, 01:14:03 pm »
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.
« Last Edit: February 23, 2013, 01:16:06 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline cbusername

  • Single posting newcomer
  • *
  • Posts: 8
Re: cout not working in codeblocks
« Reply #12 on: June 16, 2013, 02:43:37 pm »
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++.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: cout not working in codeblocks
« Reply #13 on: June 16, 2013, 06:10:55 pm »
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?)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cout not working in codeblocks
« Reply #14 on: June 16, 2013, 06:41:00 pm »
Compiler- and programerrors related question violate our forum rules.

Topic locked !