Unable to use string

This is a discussion on Unable to use string within the C++ Programming forums, part of the General Programming Boards category; When I use string as a datatype the word string is not bold like the other datatypes (int, char, double...) ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Location
    Kansas City
    Posts
    76

    Unable to use string

    When I use string as a datatype the word string is not bold like the other datatypes (int, char, double...) and I am getting compile errors. But when I change the data type from string to char for example everything works fine.

    What is wrong ?

    I am using Dev C++ 4

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    Have you included <string>

    And I used Dev-C++ 4 and it would become bold for me.

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Code:
    #include <string>
    #include <iostream>
    
    int main( void )
    {
    	std::string StrVar = "Hello there!";
    	std::cout<< "StrVar = " << StrVar;
    
    	return 0;
    }
    Compile and tell us the errors, if any

  4. #4
    Registered User
    Join Date
    Sep 2006
    Location
    Kansas City
    Posts
    76
    Thanks that works, no more errors.

    But still string is not bold.

  5. #5
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I'm pretty sure it's because string is not a language keyword. Dev-C++ surely allows you to configure this, however. My "usertype.dat" (VS 2003) file is totally pimped - almost the entire STL turns a lovely shade of purple now
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  6. #6
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Quote Originally Posted by Suchy
    Thanks that works, no more errors.

    But still string is not bold.
    It's not a primitive, and the name isn't reserved. You can legally name your own variables, classes, functions, etc. string if you chose.

    So, you could even have:

    std::string string;

    which makes an object of type std::string and names it string, and that's perfectly legal (albeit perfectly bad practice).
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  7. #7
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Suchy
    Thanks that works, no more errors.

    But still string is not bold.
    It is not a "built-in" data-type.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    > [string] is not a "built-in" data-type.
    Cat said that already.
    [string is] not a primitive, and the name isn't reserved.
    I am using Dev C++ 4
    4 point what? I'm using 4 point zero, and it's much worse than 4.9.9.2.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by dwks
    > [string] is not a "built-in" data-type.
    Cat said that already.

    4 point what? I'm using 4 point zero, and it's much worse than 4.9.9.2.
    I like saying things as simple as they are.

    Then why are you using 4.0 if it is worse that 4.9.9.2? (I am using 4.9.9.2)
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  10. #10
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Then why are you using 4.0 if it is worse that 4.9.9.2? (I am using 4.9.9.2)
    Good question . . . no particular reason, except maybe: lack of hard drive space; and the fact that executables generated by 4.9.9.2 are ten times larger (at least, even with full debugging information for 4.0). If anyone has a solution to the second problem I'd willingly delete something so I can upgrade my IDE.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 02:02 AM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 10:11 AM
  3. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 12:47 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 07:49 PM

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