![]() |
| | #1 |
| Registered User Join Date: Dec 2008
Posts: 18
| I'm new here, so please don't be so harsh on me hehe. So basically, I went out and purchased "C++ For Dummies, 5th Edition", and read the variables section. It says for strings, you use it in the following format: Code: string szMyString; So I was wondering, what's going on? Does C++ even support strings? Is there some sort of different header apart from the iostream I need to include? Oh, happy new year everyone, hope you've all had an excellent Christmas. Thanks . |
| sharkbate24 is offline | |
| | #2 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,365
| You need to #include <string>. Also, unless you have a using directive like using namespace std; or a using declaration like using std::string;, you should fully qualify the name as std::string.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is offline | |
| | #3 |
| Registered User Join Date: Dec 2008
Posts: 18
| |
| sharkbate24 is offline | |
| | #4 |
| Registered User Join Date: Apr 2006
Posts: 137
| The cool thing about strings are that you can even access individual characters like char string arrays, like so: szString[i]; If you need to convert to char array: szString.c_str(); And if you need to cut up sections, use .substr()! good luck!
__________________ ★ Inferno provides Programming Tutorials in a variety of languages. Join our Programming Forums. ★ |
| execute is offline | |
| | #5 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,439
| That's not cool, that's the biggest headache in trying to produce a std::string-compliant proper unicode-based string implementation.
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
| | #6 |
| Registered User Join Date: Dec 2008
Posts: 18
| Nice Thanks guys. |
| sharkbate24 is offline | |
![]() |
| Tags |
| cpp, strings |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Strings Program | limergal | C++ Programming | 4 | 12-02-2006 03:24 PM |
| Programming using strings | jlu0418 | C++ Programming | 5 | 11-26-2006 08:07 PM |
| Reading strings input by the user... | Cmuppet | C Programming | 13 | 07-21-2004 06:37 AM |
| damn strings | jmzl666 | C Programming | 10 | 06-24-2002 02:09 AM |
| menus and strings | garycastillo | C Programming | 3 | 04-29-2002 11:23 AM |