Thread: Error when I run an EXE file

  1. #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.

  2. #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

  3. #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?

  4. #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.

  5. #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
    		
    		
    		}

  6. #6
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    command is not a null terminated string.

  7. #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

  8. #8
    Registered User WayTooHigh's Avatar
    Join Date
    Aug 2001
    Posts
    101
    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.
    Last edited by WayTooHigh; 03-25-2002 at 06:05 PM.
    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.

  9. #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.

  10. #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...
    -

  11. #11
    Registered User dirkduck's Avatar
    Join Date
    Aug 2001
    Posts
    428
    Still no luck

  12. #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.

  13. #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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM