C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-25-2002, 04:52 PM   #1
Registered User
 
dirkduck's Avatar
 
Join Date: Aug 2001
Posts: 428
Error when I run an EXE file

Im working on a program, and I was gonna release a early version of it for some people to test, but im having this problem (im using MSVC++ 6). I set the active configyureation to release mode, then ran it from inside the IDE (build>execute), and it works perfectly. But then when I take leave the ide, copy and past the exe it made into the program directory, and run it, I get an illegal error. I dont see why, its the same exe, the only difference is if I run it from the IDE or not. Anyone know why? Thanks.
dirkduck is offline   Reply With Quote
Old 03-25-2002, 05:00 PM   #2
Registered User
 
Join Date: Aug 2001
Posts: 223
what is the error... Are you copying the file from the release folder and not the debug folder? Are there any file depencies such as ini files? When you run it from within the IDE are you using the debug run or the normal run.
Are you doing any file io? If so make sure that you are reading from the correct directory.
Have you tried running the exe from within the release folder by double clicking on it?
Also you can trying walking the program with the debugger....even if it does not error out you can still find errors this way.


hope that this helps....
__________________
zMan
zMan is offline   Reply With Quote
Old 03-25-2002, 05:07 PM   #3
Registered User
 
dirkduck's Avatar
 
Join Date: Aug 2001
Posts: 428
Thanks for the info. Ive tried debugging in, and it just crashes the debugger with 'exit code 0' I think it was. Anyway, ive narrowed it down to this line, which is in a function:
Code:
if((strcmpi(command,"end program"))==0)
If I replace it with

if(1)

Then it runs just fine. Anyone know why?
dirkduck is offline   Reply With Quote
Old 03-25-2002, 05:17 PM   #4
S­énior Member
 
Join Date: Jan 2002
Posts: 982
If I remember correctly there was a guy on the board who posted one line of code and asked people to guess what the error was a few days ago (about crashes in release build). Was it you?

Post some code.
Sorensen is offline   Reply With Quote
Old 03-25-2002, 05:33 PM   #5
Registered User
 
dirkduck's Avatar
 
Join Date: Aug 2001
Posts: 428
Heres the whole function if it helps:
Code:
bool p_end_program(char *line,int type)
{

		char command[256]={0};
		int i=0;

		for(i=0;i<11;i++)  		{
			command[i]=line[i];
			
		}
		
		//compare strings to see if it was an end program
		if((strcmpi(command,"end program"))==0)
	//	if(1)
		{
			cout << "NOTICE: found end program command"<<endl;
			c_end_program(type);  //call the other end program function
			return true;  //if it was end program, return true
		}
		return false;  //otherwise return false
		
		
		}
dirkduck is offline   Reply With Quote
Old 03-25-2002, 05:39 PM   #6
S­énior Member
 
Join Date: Jan 2002
Posts: 982
command is not a null terminated string.
Sorensen is offline   Reply With Quote
Old 03-25-2002, 05:43 PM   #7
Registered User
 
dirkduck's Avatar
 
Join Date: Aug 2001
Posts: 428
Ive tried it with {'\n'} (That would null terminate it, correct?) also, but it didn't change anything
dirkduck is offline   Reply With Quote
Old 03-25-2002, 06:00 PM   #8
Registered User
 
WayTooHigh's Avatar
 
Join Date: Aug 2001
Posts: 101
Quote:
Ive tried it with {'\n'} (That would null terminate it, correct?) also, but it didn't change anything
actually, {'\0'}, will null it. '\n' is a new line.

oh and i'd declare it like this

char command[256]=""; anything contained in quotes is automatically ended with null. therefore, since nothing is in quote the char at command[0] equals '\0', the null character.
__________________
Sometimes, the farthest point from the center is the center itself.

Your life is your canvas, it's only as beautiful as you paint it.

Last edited by WayTooHigh; 03-25-2002 at 06:05 PM.
WayTooHigh is offline   Reply With Quote
Old 03-25-2002, 07:41 PM   #9
Registered User
 
dirkduck's Avatar
 
Join Date: Aug 2001
Posts: 428
Thanks for the tip. I tried it, but it still didn't change anything.
dirkduck is offline   Reply With Quote
Old 03-25-2002, 08:57 PM   #10
I'm Back
 
Join Date: Dec 2001
Posts: 556
for(i=0;i<11;i++)
{
command[i]=line[i];
}


put command[11]='\0'

and then try...
__________________
-
ihsir is offline   Reply With Quote
Old 03-25-2002, 09:38 PM   #11
Registered User
 
dirkduck's Avatar
 
Join Date: Aug 2001
Posts: 428
Still no luck
dirkduck is offline   Reply With Quote
Old 03-25-2002, 09:52 PM   #12
Registered User
 
dirkduck's Avatar
 
Join Date: Aug 2001
Posts: 428
Just incase it helps, ill try to give a better explanation of what im doing:
I open up the workspace with my project in it, set it to compile release mode. Then go to build>execute program.exe. It compiles/links it, and It runs fine and dandy, all the way through. After that, I minimise VC++, go to the program directory>release, copy the 'program.exe' file to the base program directory. I run it from there, and when in the program it gets to the line mentioned above (the string comparison), bang, it throws up 2 illegal errors. There are about 5 more functions it calls before that which are identical to it, just very minor differences (like the length of the for...loop), which seem to run fine. Does that make more sence? Thanks.
dirkduck is offline   Reply With Quote
Old 03-26-2002, 03:05 PM   #13
Registered User
 
WayTooHigh's Avatar
 
Join Date: Aug 2001
Posts: 101
is there a reason you don't do this?
Code:
if((strcmpi(line,"end program"))==0)
__________________
Sometimes, the farthest point from the center is the center itself.

Your life is your canvas, it's only as beautiful as you paint it.
WayTooHigh is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
opening empty file causes access violation trevordunstan C Programming 10 10-21-2008 11:19 PM
Inventory records jsbeckton C Programming 23 06-28-2007 04:14 AM
Basic text file encoder Abda92 C Programming 15 05-22-2007 01:19 PM
System drdroid C++ Programming 3 06-28-2002 10:12 PM


All times are GMT -6. The time now is 08:15 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22