string data type

hi actually i wanted to use a string data type available in c++. i tried to use it like this

#include
....
....
{
string str("ALPHA");
}
it is giving an error and am using turbo 3.0 c++ compiler..
plz help me!!!

Comments

  • Correct syntax is

    #include
    using namespace std;

    However, that won't work on TC3 since it doesn't follow the C++ standard. I would strongly advise you to get a modern compiler which does.


  • i did that also but still not working i teied it on bc++ 5 also still not working!!

  • Post compiler messages.
  • : hi actually i wanted to use a string data type available in c++. i
    : tried to use it like this
    :
    : #include
    : ....
    : ....
    : {
    : string str("ALPHA");
    : }
    : it is giving an error and am using turbo 3.0 c++ compiler..
    : plz help me!!!
    :
    I'm a rookie programmer this is how i write.
    [code]
    #include //ill make it simple for you here
    #include //same thing not following standard as im bad at it too
    int main()
    {
    string str1 = "ALPHA";
    cout<<str1;
    getchar();
    }
    [/code]

    Use Visual C++ Express since most people I've asked seem to use it. Go with the flow.
  • Err... no. It is not only bad programming practice, but is also not standards compliant (It may not work on all compilers.)

    Just because it "works" does not make it "correct". [b]Don't do it.[/b]

    Your code should be this:
    [code]#include
    #include
    int main()
    {
    std::string str1 = "ALPHA";
    std::cout<<str1;
    std::cin.get();
    }[/code]

    I second Visual C++ though :-) In either case, Borland 5.5 will work as well. Cannot do much to help the OP without knowing the error message though...

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.brokenthorn.com]Website :: OS Development Series[rightbr][/link][/size]
  • i used bc++ 5 but still its not working..

  • : i used bc++ 5 but still its not working..

    As Lundin pointed out, you need to post error messages in order for us to help you.
    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.brokenthorn.com]Website :: OS Development Series[rightbr][/link][/size]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories