Thread: Problem running prime number test.

  1. #16
    Registered User
    Join Date
    Feb 2008
    Posts
    11
    same error still...
    Maybe I should try a different compiler. Any recommendations?

  2. #17
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    Quote Originally Posted by galactic_ronin View Post
    same error still...
    Maybe I should try a different compiler. Any recommendations?
    Which Windows version are you using (XP or Vista)?
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  3. #18
    Registered User
    Join Date
    Feb 2008
    Posts
    2
    Maybe it doesn't like:

    int is_prime; // Boolean flag
    is_prime = true;

    Although true should give a value of 1 wouldn't it be more accurate to cast is_prime as a bool variable?

    Newbie programmer here, too. Just putting in my 2c.

  4. #19
    Registered User
    Join Date
    Feb 2008
    Posts
    11
    Windows xp

  5. #20
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    Well there's nothing wrong with Visual Studio, perhaps your install didn't go right. I dunno. If you want to get these simple apps up and running real quick with a more minimalistic IDE try Dev C++.

    Here's the link to download Dev C++:

    http://sourceforge.net/project/downl...or=superb-east

    Of course since Dev C++ uses a different compiler than Visual Studio, you'll want to remove the #inlcude <stafx.h> from all your code.


    This doesn't mean you should give up on Visual Studio though. Use the other compiler for now so you don't feel so frustrated and so you can get back to enjoying programming. I would later try reinstalling Visual Studio.
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  6. #21
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    Note my #1 error:

    #inlcude

    lol.
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  7. #22
    Registered User
    Join Date
    Feb 2008
    Posts
    11
    Awesome. Thanks I will.
    Yeah I'm finding it very hard avoid getting frustrated right now. These inexplainable errors are the worst.

  8. #23
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    Quote Originally Posted by galactic_ronin View Post
    Awesome. Thanks I will.
    Yeah I'm finding it very hard avoid getting frustrated right now. These inexplainable errors are the worst.
    Trust me, If you continue programming, seemingly inexplicable errors will occur, and will drive you mad. But remember computers don't purposely try to drive you mad, be sure the errors are always explicable, though they may be difficult to trace.

    Sometimes it's the simplest little error that can cause you big problems. That's why modularizing things is so important (ie breaking one large problem down into smaller ones).
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  9. #24
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by dudeomanodude View Post
    What I mean is matsp was saying that your subsystem should be windows, I don't think he was explicitly telling you to change that. By "console" he meant when you choose your project type, choose a "console app."
    Unless it's changed RECENTLY, "Subsystem:Console" is the way to make a console app. If you have "Subsystem:Windows", it will make a Windowing app, which, apart from other things, requires that you have a WinMain() instead of main() - but other things change too.

    It may be other settings that got set by selecting a Windows app that cause problems too. There definitely should be some sort of indication somewhere as to what the problem is, but dudeomanodude's suggestion of starting with an "Empty" project is a good one. Also make sure that you set it as "Console".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #25
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    Quote Originally Posted by matsp View Post
    Unless it's changed RECENTLY, "Subsystem:Console" is the way to make a console app. If you have "Subsystem:Windows", it will make a Windowing app, which, apart from other things, requires that you have a WinMain() instead of main() - but other things change too.
    --
    Mats
    So the subsystem changes based on what project type you choose? I didn't know that. I guess I never really fiddled around with it either...
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  11. #26
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Try compiling from the command line with 'cl'. That way, you can check if it's the compiler or IDE that is messing it up.

    cl source.cpp

    I think that is the proper format.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why Errors in Prime Number Loop
    By wco5002 in forum C++ Programming
    Replies: 15
    Last Post: 03-22-2008, 10:49 PM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 12:55 PM
  4. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 04:25 AM
  5. Prime Number problem
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-08-2001, 08:00 PM