Results 1 to 4 of 4

Thread: a c++ newbie's simple data type question

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Question:
    Is there a String data type in c++?

    In writing a function header that would take a string value for an argument, would this work:

    void rentOne (int vidNum, String title)
    {
    }

    or do I need to use CHAR ? (I fricken hope not)

    I seem to think so, but maybe I'm remembering my Java OOP class instead..
    please help

  2. #2
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    A string is basically a bunch of chars, so yes, you will have to use char.

    Your function would look like this:

    void rentOne (int vidNum, char *title)
    {
    }


    to make a string, you must have the char and a pointer (*). I hope this clarifies any problems.
    Designer/Programmer of the Comtech Operating System(CTOS)

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Use the string library.

    Code:
    #include <string>
    using namespace std;
    
    int main()
    {
    string text;
    text = "mytext"
    text = text+"other text"
    Very easy to use.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    thanks

    Thanks for both your replies. I think inclusion of the string library is what I was recalling. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width