Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"???  (Read 5145 times)

0 Members and 1 Guest are viewing this topic.

jjbtcp

    Topic Starter


    Beginner
    Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"???
    « on: October 07, 2007, 05:31:24 AM »
    The following code works in "Dev-C++, but not in "Microsoft Visual C++ 6.0" ???

    Code: [Select]
    #include <iostream>
    using namespace std;

    int main()
    {
           cout << "\n";
           cout << "\t";
           cout << "Hello World\n";
           cout << "\n";
           cout << "\n";
           system("pause")

        return 0;
    }

    Anyone know why it won't work in "Microsoft Visual C++"?
    Regards,
                     Joshua

    AlanD

    • Guest
    Re: Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"???
    « Reply #1 on: October 07, 2007, 03:02:01 PM »
    Not quite sure why it works in one but not the other, considering there's a semi-colon missing. Try this instead:
    Code: [Select]
    #include <iostream>
    using namespace std;

    int main()
    {
           cout << "\n";
           cout << "\t";
           cout << "Hello World\n";
           cout << "\n";
           cout << "\n";
           system("pause");

        return 0;
    }

    Quick edit: I compiled it myself to make sure it works, and it does. Although I am using Visual Studio 2005. See if it works, and if not, try it without system("pause").

    Dilbert

    • Moderator


    • Egghead

    • Welcome to ComputerHope!
    • Thanked: 44
      Re: Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"???
      « Reply #2 on: October 07, 2007, 09:37:01 PM »
      Your code, before the fix, should not compile in either program. I find it odd that it did.
      "The geek shall inherit the Earth."

      jjbtcp

        Topic Starter


        Beginner
        Re: Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"???
        « Reply #3 on: October 07, 2007, 10:40:10 PM »
        Sorry, The missing semi-colon was missed when I was typing it into the forum.
        The correct code (with the semi-colon) works in "Dev" but not "Visual C++".

        Sorry about that mistake.

        and Alan when I take the system("pause") out the command prompt windows just comes up and automatically closes, so you don't get a chance to read what it prints out.
        Regards,
                         Joshua

        jjbtcp

          Topic Starter


          Beginner
          Re: Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"???
          « Reply #4 on: October 08, 2007, 01:18:15 AM »
          Would "Dev" have different libraries than what "MS Visual C++" has?
          Regards,
                           Joshua

          Dilbert

          • Moderator


          • Egghead

          • Welcome to ComputerHope!
          • Thanked: 44
            Re: Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"???
            « Reply #5 on: October 08, 2007, 04:47:09 PM »
            I've just compiled and run the above code and it works. I'm downloading Visual C++ 2005 Express Edition to see if that works. This will take about 10 minutes or so.

            EDIT: The iostream.h file should be the same on VC++ and Dev-C++.

            EDIT 2: In order to compile a Console program like this, Create a Blank Project (Under General in my VC++). Then make the .cpp file and add it to your project. After doing that, I was able to compile your program. (But what a pain it was.)

            I'll add screenshots in a moment.
            « Last Edit: October 08, 2007, 05:25:45 PM by Dilbert »
            "The geek shall inherit the Earth."

            Dilbert

            • Moderator


            • Egghead

            • Welcome to ComputerHope!
            • Thanked: 44
              Re: Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"???
              « Reply #6 on: October 08, 2007, 05:31:05 PM »
              My program doubtlessly looks different, but you'll get the main idea:







              From there, build normally. (Though personally, I just prefer Dev-C++. It's cleaner and easier. :))
              "The geek shall inherit the Earth."

              jjbtcp

                Topic Starter


                Beginner
                Re: Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"???
                « Reply #7 on: October 08, 2007, 11:21:59 PM »
                Thanks so much for your help. Although, It still doesn't work in "MS Visual C++".
                Lol I'm new to C++ and I just heard that "Dev" had it's libraries out of date or something, So I installed "MS Visual C++". But as I've realized already and with your comment:

                Quote
                (Though personally, I just prefer Dev-C++. It's cleaner and easier. Smiley)


                I'm just going to stay with "Dev". Plus it's open source - Yay!  ;D
                Regards,
                                 Joshua