Thread: application wont launch on fresh Xp

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    22

    application wont launch on fresh Xp

    Right so i tryed to dable in c++ a while back but lost my footing at the start and am now trying to regain some skill....

    so yes..i started right at the begining..on a fresh install of Xp with SP2.. but ive compiled my program and it just flashes up on screen and disappears when i try to run it....

    Code:
     
    #include <iostream>
    
    int main()
    {
        std::cout << "oldest code ever...!\n";
        return 0;
    }
    any ideas?

    khris

  2. #2
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    After the std::cout line insert std::cin.get().
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    22
    yes i see...otherwise the program has nothing to stay open for... cheers

  4. #4
    Registered User
    Join Date
    Apr 2005
    Posts
    22
    another one for you...

    this is the code i get from a tutorial website:
    Code:
     #include <iostream.h>
     int main()
     {
          int x = 5;
          int y = 7;
          cout "\n";
          cout << x + y << " " << x * y;
          cout "\n";
          return 0;
     }
    this hasnt a hope of workign on my pc... im not sure if this is because of the compiler or not...
    but if i put this :
    Code:
    #include <iostream>
    int main()
    {
        int x = 5;
        int y = 7;
        std::cout "\n";
        std::cout << x + y << " " << x * y;
        std::cout "\n";
        return 0;
    }
    it nearly works...apart from compiler says it expects ; before string constant..... i dont no where to go now.....

    khris

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > im not sure if this is because of the compiler or not
    Nah, just an old website teaching old C++, where your compiler accepts new C++.

    One of the major differences in source code is the use of namespaces, such as the std:: you have in front of your cout calls.

    > std::cout "\n";
    Try std::cout << "\n";
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Also try
    Code:
    cout << endl << x + y << " " << x * y << endl;
    Then remove the cout << "\n".
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  7. #7
    Registered User
    Join Date
    Apr 2005
    Posts
    22
    yep that works now.. so its going to be an effort in itself learning from this site.... hmm...might look around for somewhere else...

    cheers,
    khris

  8. #8
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Pick up a good book.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  9. #9
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    One of the problems with online tutorials is the fact some of them are pre-standard. ie: teaching older syntax than more compliant compilers would cough errors up at. The tutorial on this site is a good one and uses modern syntax so perhaps try there. Or do as manutd suggested about the book. Oh, and stay away from herb stuilt books ( spelling ?) he is awful.
    Double Helix STL

  10. #10
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    schildt?
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  11. #11
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    >>schildt?

    Yeah thas the guy. I used to own one of his books. Waste of money reading about buggy code and poor practices.
    Double Helix STL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I launch an application using system{}
    By cpnoob in forum C++ Programming
    Replies: 2
    Last Post: 06-11-2006, 11:23 AM
  2. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  3. Bringing an Application to the Front in XP
    By Davros in forum Windows Programming
    Replies: 5
    Last Post: 11-25-2003, 10:59 PM
  4. Application Termination Problem in Windows XP
    By wasabee in forum Windows Programming
    Replies: 2
    Last Post: 04-11-2003, 12:53 PM
  5. Borland CBuilder -> Launch external application
    By stovellp in forum Windows Programming
    Replies: 1
    Last Post: 01-11-2003, 07:25 PM