error

This is a discussion on error within the C++ Programming forums, part of the General Programming Boards category; I will try to execute the code without using any IDE. I wrote the code in notepad can you tell ...

  1. #16
    Registered User
    Join Date
    May 2007
    Posts
    13
    I will try to execute the code without using any IDE. I wrote the code in notepad can you tell me how to execute it through command line now?

  2. #17
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Wrote the code in notepad? Are you nuts?
    That is no way to go about programming. If you just don't want the hassle of using the command line, configuring installations to work, yada, yada, then get Visual Studio.
    Install. Use. Ctrl+F5 to run. It will keep the console open for you to see.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by Elysia View Post
    Wrote the code in notepad? Are you nuts?
    That is no way to go about programming.
    I use plain text editors all the time.

    To the OP, your window won't stay open because there is a trailing newline from when you read in the last int. two cin.get()s should fix it.

  4. #19
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Quote Originally Posted by robwhit View Post
    I use plain text editors all the time.
    I think you need to learn to use IDEs too...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #20
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    I can use an IDE, I just like text editors.

  6. #21
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    how to execute it through command line now?
    Start -> Run -> Open cmd
    Then you use cd to change to the directory where the program compiled by Dev-C++ is, and then run it using its filename.

    two cin.get()s should fix it.
    The cin.ignore() that was shown in the various articles linked to, and finally in my own posted example, should fix it too, and better in that it is more descriptive and flexible.

    Wrote the code in notepad? Are you nuts?
    I agree, but only because Notepad does not have tools that support programmer productivity. Some other text editors (some of which are almost IDEs unto themselves) do, and these are fine for programming.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #22
    Registered User
    Join Date
    May 2007
    Posts
    13
    It works now. I have got the latest version of dev. Thanks everyone.

  8. #23
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Quote Originally Posted by laserlight View Post
    I agree, but only because Notepad does not have tools that support programmer productivity. Some other text editors (some of which are almost IDEs unto themselves) do, and these are fine for programming.
    But it's also good to have compile/linking facilities and debugging facilities in the IDE too, in which some editors fail. That's why Visual Studio is such a terrific IDE.
    Next best to none is an editor supporting programming activity, though.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #24
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    But it's also good to have compile/linking facilities and debugging facilities in the IDE too, in which some editors fail. That's why Visual Studio is such a terrific IDE.
    All IDEs should have compile/linking and debugging facilities integrated, otherwise they are not IDEs at all. An editor that integrates those out of the box is actually an IDE. So Visual Studio is not a terrific IDE because it includes them, but because it includes them well.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #25
    I eat babies
    Join Date
    Jan 2008
    Location
    la-la-land
    Posts
    31
    your code
    Code:
       
       
       #include <iostream> 
     
      
       int main()
       {
          
          int number1; 
         int number2; 
         int sum; 
    
         std::cout << "Enter first integer: "; 
         std::cin >> number1; 
    
         std::cout << "Enter second integer: "; 
         std::cin >> number2; 
    
        sum = number1 + number2; 
    
         std::cout << "Sum is " << sum << std::end1; 
    
         return 0; 
    
      }
    my code

    Code:
    #include <iostream>
    using namespace std;        //eliminates need for std::
    
    int main()
    {
          
         int number1;
         int number2; 
         int sum; 
    
         cout << "Enter first integer: ";             //because of using namespace std you dont need std
         cin >> number1;          //again no std::
    
         cout << "Enter second integer: ";        //no need for std::
         cin >> number2;              //no need for std::
    
    
         sum = number1 + number2; 
    
         cout << "Sum is " << sum << "\n\a";     //no std::
    
    system ("pause");         //pauses program at the end so you can see result
    
    return 0; 
    }

  11. #26
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    This is a matter of preference.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

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