Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: cbusername on February 21, 2013, 02:31:45 pm

Title: cout not working in codeblocks
Post by: cbusername 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;
}
Title: Re: cout not working in codeblocks
Post by: jarod42 on February 21, 2013, 02:37:50 pm
Do you check the 'pause when execution ends' in build target options ?
Title: Re: cout not working in codeblocks
Post by: cbusername 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.
Title: Re: cout not working in codeblocks
Post by: cbusername 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.
Title: Re: cout not working in codeblocks
Post by: jarod42 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 ?
Title: Re: cout not working in codeblocks
Post by: cbusername 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.
Title: Re: cout not working in codeblocks
Post by: jarod42 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 ?)...
Title: Re: cout not working in codeblocks
Post by: cbusername on February 22, 2013, 02:34:25 pm
it is in c:users/orindombanerjee/desktop/bin/debug

orindom banerjee is my name.
Title: Re: cout not working in codeblocks
Post by: cbusername on February 22, 2013, 02:58:44 pm
c:\users\orindombanerjee\desktop\bin\debug

no special directory. It stored it there by default.
Title: Re: cout not working in codeblocks
Post by: jarod42 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....
Title: Re: cout not working in codeblocks
Post by: 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.
Title: Re: cout not working in codeblocks
Post by: stahta01 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 (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)

Tim S.
Title: Re: cout not working in codeblocks
Post by: cbusername 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++.
Title: Re: cout not working in codeblocks
Post by: Alpha 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?)
Title: Re: cout not working in codeblocks
Post by: Jenna on June 16, 2013, 06:41:00 pm
Compiler- and programerrors related question violate our forum rules.

Topic locked !