Cout scope issue

I am having trouble with cout. In my main function it kicks the ouput to the console like it should. However, when I call it from a function or method the output does not appear. Any ideas?

This is a console application on VC++ 4.0

#include <iostream.h>

int cubeByValue (int);
int cubeByReference(int *);

void printCharacters(const char *);

int main()
char myString[] = "print characters of a string";
int number = 5;

cout << "The original value of number is " << number;
/* number = cubeByReference(&number);*/
number = cubeByReference(&number);

cout << "\nThe new value of number is " << number << endl;


return 0;

int cubeByValue (int n)
cout << "cubeByValue";
return n * n * n;
int cubeByReference (int * nPtr)
return *nPtr * *nPtr * *nPtr;

void printCharacters(const char * sPtr)
for (; *sPtr != '\0'; sPtr++)
cout << *sPtr;

cout << "hello world";
This is a console application on VC++ 4.0

That's old, and it matters! Update your tools if you can.
C++ was standardized in 1998. Post '98 tools should support C++98 well enough.
(One suggestion at the end.)

This is what your program prints for me:
The original value of number is 5
The new value of number is 125
print characters of a stringhello world

I'm using MinGW 4.7+ command line tools.

If you're old school, Borland offers its old compiler for free.
Guys, Thank You very much for the help. The article above helped. I needed to flush the output to get it to show. So I added "<< flush" to the end of my cout statements in the functions and it worked.

I also think the advice to upgrade is spot on and right.

Thanks again
Topic archived. No new replies allowed.