473,325 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Program crashes when not loaded from inside Visual C++ 6.0

11
Hi guys, my first post here, im desperately in need of help! :)

When i am running Visual C++ 6.0 and have my .cpp file opened, i compile, build and run the program, it all works fine. But if i close Visual and try to run the program .exe from the Debug folder, it crashes half way through the program :( i dont understand why ..i will refrain from posting the code for my program since its quite long and messy.. hope anyone knows a solution.
Aug 20 '07 #1
10 2808
sicarie
4,677 Expert Mod 4TB
Hi guys, my first post here, im desperately in need of help! :)

When i am running Visual C++ 6.0 and have my .cpp file opened, i compile, build and run the program, it all works fine. But if i close Visual and try to run the program .exe from the Debug folder, it crashes half way through the program :( i dont understand why ..i will refrain from posting the code for my program since its quite long and messy.. hope anyone knows a solution.
Do you know where it crashes? Try using print statements as debug statements (ie: cout << "Reached 'double calculate_average()' function\n";), you can see where it goes down.

I'm guessing you coded a relative path, and then are executing from a different location, but that's just a wild guess with the information provided...
Aug 20 '07 #2
Deviate
11
thanks for a really fast reply! :)

"I'm guessing you coded a relative path, and then are executing from a different location, but that's just a wild guess with the information provided..."

-sorry, im not even sure i know what that means :o when i first started making the program i did the usual "win32 console application + C++ source file thing" and then chose the desktop as the destination to save it. So there is a folder for my program and inside it is the .exe for my program which i just double click, and thats when it crashes half way through. But when i double click the .cpp file and compile+build+run it doesnt crash :/ very strange ..and about using cout<< to be able to see exactly where it crashes, thx for the advice, will try that, probably tomorrow since ive had it for today with this ;) hehe ..but as far as i can see its like this : (in the program) "to solve using QR, press 1:
to solve using normal equations, press 2:"

So when i press 1 or 2, it crashes directly after i press enter.. but like ive said when its loaded from inside Visual C++, it proceeds to calculate using the chosen method from above, like it should.. anyways, this is getting long :P

thx to anyone who has more advice for me!
Aug 20 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
I suspect the program you are executing manually is not the program being compiled by VC 6.0.

Do this:

1) Create new C++ Console Application project on a new path YOU SELECT.
2) Move your .cpp and .h files to that project folder
3) Add the .cpp files to the project
4) Build the project
5) Execute the code in VC 6.0
6) Navigate to the Debug folder for that project
7) Execute the .exe by double clicking
Aug 20 '07 #4
Deviate
11
Thanks for a swift reply :)

But hmm! I did as you said, created a new console application, added the .cpp file from the old folder, built and executed from within VC, which worked. But when i closed down VC and launched the .exe from the new folder, the same problem, crashes at the same place! :S Now i was wondering, could it be that the program just terminates after its run all the code? I mean, usually when it has finished running, it just says "press any key to continue" . Maybe if i put the whole of main() inside a do/while loop, with the question "do you want to run the program again? y/n : " .. at least thats an easy way to figure out if all the code is actually processed. Because, when the program crashes, there is only cout<< to the screen, maybe it actually does the whole cout<< and then terminates, but does it too fast for me to see it ..

Will keep you guys posted when i try adding the do/while loop! Thx to both for the help :)
Aug 20 '07 #5
Deviate
11
WOOP! Sorry for the double post, but i JUST wanted to say that i was indeed right ! :) i just added the do/while around all the code in main() which then requires a y/n answer, this keeps the program from terminatin after the code has been run :) so yeah..

This thread can be closed now, got my answer :) Thx to all who posted! What a beginners error :/ *blush* hehe :p
Aug 20 '07 #6
weaknessforcats
9,208 Expert Mod 8TB
Hold on there a minute.

I mean, usually when it has finished running, it just says "press any key to continue" .
You didn't mention this before.

The "press any key to continue" is provided by Visual Studio at the end of
main() when you select Start Without Debugging.

That black window might look like the command interpreter, but it's not. It's just a black window. Notice the Command Interpreter has a prompt: C:\>.

Your crash might he related to memory corruption as cleanup from your program can be deferred until after the closing brace of main().

Indeed, when main() finishes, your program is done.

You never really said how the program crashed. Like what was the error?
Aug 21 '07 #7
Deviate
11
sorry about that cats! I wasnt aware *blush* i sort of expected the "press any key to continue part" to also be there when i launched the .exe and that was essentially the mistake.. in fact my program didnt -crash- , it actually just was finished.. thats why adding the do/while around it solved the problem .. so sorry for not posting that info before, that was just due to my lack of basic knowledge of Visual :p apologies for that hehe..
Aug 21 '07 #8
weaknessforcats
9,208 Expert Mod 8TB
No apologies required.

All of us, at one time or another, have just looked at the screen and said: "What????....."
Aug 21 '07 #9
Banfa
9,065 Expert Mod 8TB
No apologies required.

All of us, at one time or another, have just looked at the screen and said: "What????....."
Usually first thing every morning when trying to work out what I did yesterday :D
Aug 21 '07 #10
Tops
4
I had just a quick question, what are you using for the loop?
I'm new to this C++ and am having the same problem, my program executes way to fast to get the solution and using the code to run again would be perfect.
Its just a simple program to find the area of a rectangle.
Thanks!
Jan 21 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: James | last post by:
Im having trouble building/running a program which was written under Visual Studio 2000 & .NET Framework 1.0. Im now using a new installation of .NET 1.1 with Visual Studio 2003, otherwise there...
4
by: Matt Sawyer | last post by:
I am attempting to use an API (CxApiOem.dll) that has a large number of defines and complicated structs. It's just too much hassle to attempt to use DLLImport to make the desired API calls. ...
3
by: Stevie_mac | last post by:
It might be me but... I dont seem to get a Page_Load event when a opening an ASPX in an iFrame. I do geta Page_Load event when an item on the ASPX (inside the iFrame) is clicked but then...
8
by: Paul Bromley | last post by:
I am about to release the second version of a program that I started writing 12 months ago. The first version worked fine on 98 upwards. This version seems to crash on Windows 98. I realise that...
2
by: manuthomas23 | last post by:
Here is the code: #ifndef M3DCAMERA__H__ #define M3DCAMERA__H__ class M3DEngine; /** Micro3D Camera class. */
10
by: Nicholas Zhou | last post by:
Sorry if this sounds stupid. I am a total newbie.... Can I compile C program in Visual Studio 2005 IDE? I wrote the simple "Hello World" program in it: ------------------------------------ ...
41
by: z | last post by:
I use Visual C 2005 to develop my programs. One in particular is crashing in very specific and hard to replicate situations, made worse by the fact it only crashes when run -outside- the dev - as...
2
by: Z.K. | last post by:
I was wondering if someone could tell me why I get this message and how to prevent it. If I hit continue, it runs fine, but want to know what I am doing wrong so I won't get this error in the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.