Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i hate devc++
#1
i'm trying to figure out why this wont work in devc++

Code:
#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 variable
                  cout << "\n"; // output a newline
                  func2();
                  }
                  
                  void func2()

devc++ is really about to piss me off.. i cant get it to compile crap, it couldnt compile "hello world" on i good day, i swear... does anybody know of a better "free" compiler?

PLEASE HELP!!
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#2
i havent really used devc++ that much, just because everytime i use it, i come across some type of problem

this compiles fine
Code:
#include <iostream>
using namespace std;

int global_var;

int main()
{
    int holder;
    global_var = 100;
    cout << global_var;
    cin >> holder;
    return 0;
}

wich means the problem isnt global variables, wich is a good thing
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#3
First off, DevC++ is an IDE, not a compiler. It provides an environment for gcc, which is the standard "free" compiler. C++ itself is a standardized language, it is the same across all compilers.

This works fine for me. Prefix the global variables with "::":
Code:
#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();
        }
        system("PAUSE");
        return 0;
    }
            
void func1()
   {
       cout << "count: " << ::count; // access global variable
       cout << "\n"; // output a newline
       func2();
   }

                
void func2() {}
It was probably in a namespace conflict with std::count or something.
Reply
#4
Quote:It was probably in a namespace conflict with std::count or something.
That's right, Jofers: http://support.roguewave.com/support/doc...count.html

Changing your variable name would be just as good. :-)
Maybe "myCount" or something?
974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Reply
#5
Quote:i hate devc++

Me too! :evil:
Reply
#6
I don't use DevC++ too. Instead, I stick with GNU make. It's simple and it works. 8)

Regards,
Mark
Reply
#7
Quote:I don't use DevC++ too. Instead, I stick with GNU make. It's simple and it works. 8)

Regards,
Mark
i stick with freebasic, because its simpler and works. Tongue
[Image: freebasic.png]
Reply
#8
i have devc++, but since i'm not a hard-core c++ programmer, i don't complain when i use it.....it's only for testing code..that's about it.

you may find it better practice (not really, but hey) to create your own namespace, thus you won't get any conflicts with your variables, but you constantly have to have YourNameSpace::Yourvar

oz~
Reply
#9
One compiler I like (it's a compiler/ide/everything thing lol) is Pelles C
http://www.smorgasbordet.com/pellesc/

this is C, not C++ ;-)
hen they say it can't be done, THAT's when they call me ;-).

[Image: kaffee.gif]
[Image: mystikshadows.png]

need hosting: http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
Reply
#10
By the way, did you download all of the Dev-C++ updates? That may be something you'll want to consider. . .
974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)