#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Brazil
    Posts
    15
    Rep Power
    0

    .EXE doesn´t work... (Newbie)


    Hi, after I built a little program I tried to use just the file .EXE on another computer, but I was unable to execute it. Why ?? Do I need to have more files accompaning this .EXE file ??

    Thank you !!!
  2. #2
  3. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    most likely you probably double clicked the exe im guessing? what you need to do is open up a command prompt, and change to the directory the exe is located and then run it. another neat little trick people use is to insert this as the last line in your program:
    Code:
     cin.getch()
    that will wait for input from the user b4 closing the window. if you add that code, then you will be able to just double click the exe instead of having to run it from the command prompt.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2001
    Posts
    1,473
    Rep Power
    15
    If you compiled it with a student or learning edition of Visual C++, you cannot run it on another computer--you have to upgrade to the Professional edition to do that. That's to prevent you from distriubuting apps--e.g commercial development--without paying the full fee.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    20
    Rep Power
    0
    cin.getch() completely destroyed my program and I couldnt compile anything till I cleared out all my projects and restarted my comp....but as for the other one(command line) that helped :-D Where exactly does cin.getch() go? before or after the return 0; line? I put it before, so it might've been my mistake, otherwise my compiler doesnt like that command :-P
  8. #5
  9. Left due to despotic ad-min
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Posts
    1,044
    Rep Power
    13
    cin.getch() simply reads a character from standard input (eg ther keyboard). However (IIRC) it waits for the Enter key to be hit before it returns the first character entered.

    The reason it probably "broke your program" is that, to use the cin object (or cout, cerr) you also need to #include <iostream> (and probably also a

    using namespace std;

    as cin lives in the std namespace.

    Note: std::cin is also C++ specific, and not available from standard C.
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    20
    Rep Power
    0
    hmm i think my computer was just going nuts, i think when i tried the compile i was running too much and it crashed it, thus making the compiler act weird. anyway, i think i understand that now, very useful, thanks :D I'm on day 6 of the 21 day program of learning C++, but something tells me that will translate to many months :p

IMN logo majestic logo threadwatch logo seochat tools logo