Advertisement

String problemos

Started by April 14, 2002 01:19 PM
7 comments, last by Rimrok 22 years, 7 months ago
Hello boys n girls! Quick question: How do I use strings in structures? This: struct hello{ string HeyDude; }; Doesn't work.. Bye for now! The way to the right path is through pain, sweat and tears. [edited by - rimrok on April 14, 2002 2:20:36 PM]
The way to the right path is through pain, sweat and tears.
quote: Original post by Rimrok
Doesn''t work..

That''s nice. Now tell use why it doesn''t work. Are you sure it knows (through a using directive somewhere) that you want std::string and not just string? Are you including the string header at all?

Advertisement
You need to put the following at the top of each file wherever you are declaring a string.

using namespace std;

Also be sure you include &ltiostream> NOT &ltiostream.h&gt. Also include &ltstring> NOT &ltstring.h&gt.


For Example:

              #include <iostream>#include <string>using namespace std;            


Hope this helps.


P.S. Thanks Oluseyi for the help with HTML

[edited by - aNonamuss on April 16, 2002 11:19:20 PM]
------Shop for the Lowest Price!Then, Check a Reseller's Rating Before You Purchase!
He meant "include <iostream> and not <iostream.h>"

Also, do NOT put using namespace std; in a header file, but there, write fully qualified names (i.e. std::string), because the whole purpose of namespaces are to avoid name collisions. If you put the using declaration in the header, anybody who uses your header will have the whole std namespace imported in the global namespace, whether they want it or not.

And that is bad.

[Questions (STFW) | GDNet Start Here | GDNet Search | Forum FAQ | Google | Asking Smart Questions ]
[Docs (RTFM) | MSDN | SGI's STL | OpenGL | File formats]
[C++ Must Haves (RTFS) | MinGW | Boost | Loki | FLTK | SDL ]

Stolen from Magmai Kai Holmlor, who held it from Oluseyi, who was inspired by Kylotan...

[edited by - Fruny on April 14, 2002 3:09:43 PM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Nice.. Thank you!

Null and Void:
I'm sorry, I'll try to be more specific next time..
As for now, I think aNonamuss caught the source of my problem anyway..

Damn you guys are fast to reply!


[edited by - rimrok on April 14, 2002 2:42:02 PM]
The way to the right path is through pain, sweat and tears.
Yea,

Fruny is right. That is what I meant. How do I put those symbols in Fruny? I read the FAQ, but it didn''t mention anything about using angle brackets.

Thanks
------Shop for the Lowest Price!Then, Check a Reseller's Rating Before You Purchase!
Advertisement
Strings are resources!


////////////////////////////// .rc file//////////////////////////
STRINGTABLE
{
ID_STRING1, "string 1"
.
.
.
.
}

////////////////////////////////////////////////////////////////

///////////////////////// load string//////////////////////////

char load_string[80]

LoadString(hinstance, ID_STRING1, load_string,80))

/////////////////////////////////////////////////////////////
quote: Original post by aNonamuss
Yea,

Fruny is right. That is what I meant. How do I put those symbols in Fruny? I read the FAQ, but it didn''t mention anything about using angle brackets.

Thanks


It is an HTML issue, not a forum issue. You need to write &lt; or &gt;


[Questions (STFW) | GDNet Start Here | GDNet Search | Forum FAQ | Google | Asking Smart Questions ]
[Docs (RTFM) | MSDN | SGI''s STL | OpenGL | File formats]
[C++ Must Haves (RTFS) | MinGW | Boost | Loki | FLTK | SDL ]

Stolen from Magmai Kai Holmlor, who held it from Oluseyi, who was inspired by Kylotan...
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote: Original post by aNonamuss
How do I put those symbols in...?

You''ll have to use HTML, because the board interprets a less-than symbol directly followed by non-whitespace as an attept at an HTML tag. Use &lt; for less-than, and optionally &gt; for greater than. How did I type an ampersand? &amp;


[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!

This topic is closed to new replies.

Advertisement