Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Global variable problem
Global variable problem [message #774700] Wed, 04 January 2012 07:21
Eclipse UserFriend
Hi people!

I'm a beginner learning C++ via Mac Leopard. I can't run the following code because Eclipse does not recognise the global variable 'count'. Can someone advise how I can get this code to build on Eclipse?

Thanks.

#include <iostream>
using namespace std;

void func1();
void func2();

int count; // this is a global variable

int main()
{
int i; // this is a local variable

for(i = 0; i < 10; i++) {
count = i * 2;
func1();
}

return 0;
}

void func1()
{
cout << "count: " << count; // access global count
cout << '\n'; // output a newline
func2();
}

void func2()
{
int count; // this is a local variable.

for(count = 0; count < 3; count++) cout << '.';
}

Previous Topic:How to change the size of the GUI elements (window/tab borders and buttons size)
Next Topic:The ressource folder in visual c++ 6.0
Goto Forum:
  


Current Time: Thu Jul 17 12:41:55 EDT 2025

Powered by FUDForum. Page generated in 1.06534 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top