Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   My programs aren't running...( no errors) (http://www.programmingforums.org/showthread.php?t=15199)

wannabe7 Feb 16th, 2008 1:29 PM

My programs aren't running...( no errors)
 
Some of the programs that I run on Dev+-C++ won't run for some reason. Does this occur often? If so, what can I do? (I don't have a code with me but I'm sure that errors isn't the reason why my program isn't running.)

If anyone can help, Thanks!

Ancient Dragon Feb 16th, 2008 4:28 PM

Re: My programs aren't running...( no errors)
 
>> but I'm sure that errors isn't the reason why my program isn't running
Hate to be the bearer of bad news but 99.99999% of the time that is exactly the reason a program won't run. If not syntax errors then logic errors.

>>If anyone can help
Impossible without the source code. I don't have my crystle ball with me today or I'd ask the Gods about your code :)

wannabe7 Feb 21st, 2008 8:09 PM

Re: My programs aren't running...( no errors)
 
Ok, here's a simple program that I recently wrote (and won't run):
:


#include <iostream>
using namepace std;

int main()
{
    int length, width

    cout << "Enter the length: ";
    cin >> length;

    cout << "Enter the width: ";
    cin >> width;

    cout << "The area is: ";
    cout << length * width;

    return 0;
}


wannabe7 Feb 21st, 2008 8:09 PM

Re: My programs aren't running...( no errors)
 
Bump. Thanks.

Jimbo Feb 21st, 2008 8:32 PM

Re: My programs aren't running...( no errors)
 
Define "won't run". Do you get any reaction out of your IDE when you try to run it? Maybe something just pops up and goes away or something? Do the tool windows get changed (not familiar with Dev-C++ sorry)?

Sane Feb 21st, 2008 9:02 PM

Re: My programs aren't running...( no errors)
 
You misspelled "namespace".
You're missing a semi-colon on line 6.

:

#include <iostream>
using namespace std;

int main()
{
    int length, width;

    cout << "Enter the length: ";
    cin >> length;

    cout << "Enter the width: ";
    cin >> width;

    cout << "The area is: ";
    cout << length * width;

    return 0;
}


mattireland Feb 22nd, 2008 5:32 AM

Re: My programs aren't running...( no errors)
 
Try putting in a
:

SYSTEM("PAUSE");
at the end. This will make the prompt stay about for longer so you'll be able to actually see the output of the program. I think it only works in the latest version of Bloodshed Dev C++ though....

Ooble Feb 22nd, 2008 5:43 AM

Re: My programs aren't running...( no errors)
 
That'll only work on Windows under standard circumstances - there are any number of changes to the OS or file system that could cause that to fail. And it definitely won't work on *nix - including Mac OS.

Try this:
:

cout >> "Press any key to exit." >> endl;
cin.get();


grumpy Feb 22nd, 2008 2:45 PM

Re: My programs aren't running...( no errors)
 
To explain what's happening. The code is "running". However, the program completes and terminates. The system therefore determines that the console window (which was created specifically for the purpose of running the program) to which output has been written is no longer needed, so it destroys the console window. Net effect is that the program disappears before you can see its output.

Sane Feb 22nd, 2008 2:53 PM

Re: My programs aren't running...( no errors)
 
I'm trying to figure out where the confusion still lies. He posted code that clearly had some errors in it. It also had cin statements before the console could even terminate, so that could not be the problem.

I think his compiler was just giving him heck for his missing semi-colon. But perhaps that wasn't a good example of his problem.


All times are GMT -5. The time now is 6:07 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC