A sixth noobie question-string?

This is a discussion on A sixth noobie question-string? within the C++ Programming forums, part of the General Programming Boards category; Various tutorials involve #include "string6.h" or #include <string> I have Borland 5.02-what do I use? The below code does not ...

  1. #1
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167

    A sixth noobie question-string?

    Various tutorials involve #include "string6.h" or #include <string>
    I have Borland 5.02-what do I use?

    The below code does not work at all and apparently the problem has to do with the fact that im trying to use a string

    Code:
    #include <iostream.h>
    #include <string>
    
    int main()
    {
        string name;
        int ID;
    
        cout << "Enter your name ";
        cin >> name;
    
        cout << "Enter your ID number ";
        cin >> ID;
    
        cout << "Hello " << name << " or should I say " << ID << endl;
    
        return 0;
    }

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    I suggest you use a newer compiler because few can help you
    with that old compiler. I suggest Dev c++.

  3. #3
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    I cant afford a newer one :<

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    The suggestion i made is a free compiler.Dev C++

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Take the ".h" from the iostream header and add "using namespace std; under the string header. There are other ways of doing this...

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main()
    {
        string name;
        int ID;
    
        cout << "Enter your name ";
        cin >> name;
    
        cout << "Enter your ID number ";
        cin >> ID;
    
        cout << "Hello " << name << " or should I say " << ID << endl;
    
        return 0;
    }
    ...look up namespaces in you help/book/tutorial.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by adrianxw
    Take the ".h" from the iostream header and add "using namespace std; under the string header. There are other ways of doing this...
    Problem is, he uses a VERY old compiler. And apperntly it doesnt
    use <iostream> or <string>. Hopefully he'll follow my link. *hint*

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Borlands current compiler is 5.5, so it's not really that old, (if that is what he means of course). If he can't use the standard header inclusion he'll have to use the ".h" style, but if he is using a truly ancient compiler, the std string classes might not be implemented.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  8. #8
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    I got dev-c++ now but I get about a 1000 errors when i try to compile something

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Noobie
    I got dev-c++ now but I get about a 1000 errors when i try to compile something
    DEV C++ specific problems should be redirected to a DEV specific
    forum, or you could adress the manual.

  10. #10
    Much older and wiser Fountain's Avatar
    Join Date
    Dec 2001
    Location
    Engeeeerland
    Posts
    1,158
    Originally posted by adrianxw
    Borlands current compiler is 5.5, so it's not really that old, (if that is what he means of course). If he can't use the standard header inclusion he'll have to use the ".h" style, but if he is using a truly ancient compiler, the std string classes might not be implemented.

    Not quite. Our Uni has been running Borland 6.0 since Sept 2002. Just for info....
    Such is life.

  11. #11
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    The compiler quoted on Borlands website is still 5.5...

    http://www.borland.com/products/down...cbuilder.html#

    ...but whatever.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  12. #12
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by adrianxw
    The compiler quoted on Borlands website is still 5.5...
    The .NET compiler isn't officialy finished yet either but you can
    already get it.

  13. #13
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> but you can already get it.

    As I said, whatever, the point I was making is that if he, as he says, is using 5.02, it is not really all that old. I suspect he was not using that however, he probably has an old copy of Turbo C or something. It is immaterial anyway, he has downloaded, and is having trouble with Dev-C++ now!

    another noobie question
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  14. #14
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Yeah,know. Dev has getch() right? I posted some code for him to
    test, haven't heard a reply yet.

  15. #15
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Various tutorials involve #include "string6.h" or #include <string>
    Many new programmers get confused by all the string headers.. I know I was.

    <string> contains the STL string definition
    <string.h> depricated header which contains various functions for working with c-style strings (char *)
    <cstring> essentially the same as <string.h> except its definitions are wrapped in namespace std. This, unlike string.h is a standard header. string.h is included in most modern compilers for the purposes of legacy code.

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

Similar Threads

  1. Reusing a string pointer question
    By chiefmonkey in forum C++ Programming
    Replies: 3
    Last Post: 05-06-2009, 05:53 PM
  2. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 04:58 PM
  3. Next Question...
    By Azmeos in forum C++ Programming
    Replies: 3
    Last Post: 06-06-2003, 03:40 PM
  4. String array question
    By gogo in forum C++ Programming
    Replies: 6
    Last Post: 12-08-2001, 06:44 PM

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