Thread: Dev-C++

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    6

    Dev-C++

    Hi

    I was wondering if anyone could help me with my program I'm using the newest version of Dev-C++ here is what I typed:

    Code:
    #include <iostream>
    int main()
    {
        int x = 5;
        int y = 7;
        std::cout << endl;
        std::cout << x + y << " " << x * y;
        std::cout << end;
        return 0;
    }
    and here is the error message I get:

    'endl' undeclared (first use this function)
    'end' undeclared (first use this function)

    if anyone can tell me what to do that would help alot. Thanks in advance

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    endl is in the std namespace as well.

    you need
    Code:
    std::cout<<std::endl;
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    If you weren't aware of it, you can also eliminate all the std::'s by putting the line
    Code:
    using namespace std;
    after your include directives. There's no technical difference that I'm aware of - it's just a matter of style preference.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6
    Thanks everyone for your help

  5. #5
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by sean_mackrory
    If you weren't aware of it, you can also eliminate all the std::'s by putting the line
    Code:
    using namespace std;
    after your include directives. There's no technical difference that I'm aware of - it's just a matter of style preference.
    the technical difference is that by doing that you can no longer use any other cout's or endl's in any other namespaces... but having something else with the same name as anything in the standard namespace is very poor programming practice.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  6. #6
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Use a Basic template like this for evrey program you create, then you can eliminate all the
    errors you had example:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    
    cout << "delete me" << endl;
    
    return 0;
    }

  7. #7
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    I would actually recommend not doing that... sure it's easy, but using the using namespace std; line should probably not outlive your early-to-mid learning stages... it'd be better to put
    Code:
    using std::cout;
    using std::endl;
    that way you'll know what exactly comes from the standard library. for examle, I'll bet you'd never know why this code is wrong just by looking at it:
    Code:
    #include<iostream>
    
    int main()
    {
        std::cout<<"Hello World"<<std::endl;
        ifstream file("file.txt");  //open a file
        file.close();  //close the file
        return 0;  //return 0 to the OS
    }
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  8. #8
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    216
    it should be std::ifstream, right?
    and also <fstream> should be included

  9. #9
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by Antigloss
    it should be std::ifstream, right?
    and also <fstream> should be included
    yes. although I didn't mean to exclude <fstream>
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Whats better, C-Free or Dev C++??
    By i_can_do_this in forum Tech Board
    Replies: 10
    Last Post: 07-07-2006, 04:34 AM
  2. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 01:05 AM
  3. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 08:43 PM
  4. DEV C++ Limitations?
    By Kirdra in forum Game Programming
    Replies: 3
    Last Post: 09-09-2002, 09:40 PM
  5. Tutorial about Bloodshed Dev!
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 11-13-2001, 07:42 PM