|
This thread is locked; no one can reply to it. |
1
2
|
stl string and allegro text functions |
Rick
Member #3,572
June 2003
|
OK, so no, your example doesn't work. How do I increase the length of the string? [EDIT} I think that is what you were trying to get me to find ======================================================== |
X-G
Member #856
December 2000
|
Quote: How do I increase the length of the string? Put something on the end. Or insert at index 0, which is just at the end of the string, and not 1 index into oblivion. -- |
Rick
Member #3,572
June 2003
|
Oh well that's not what I expected because my index does start at 0 and that didn't work for me. ======================================================== |
ImLeftFooted
Member #3,935
October 2003
|
Maybe you're misinterpretting the crash. |
Neil Walker
Member #210
April 2000
|
Quote: Wrong language. This is the problem when you have to code in 5 languages at once per day Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Rampage
Member #3,035
December 2002
|
Which compiler can accept five languages at once, being java one of them? -R |
ImLeftFooted
Member #3,935
October 2003
|
Quote: Which compiler can accept five languages at once, [java being] one of them? gcc |
Rampage
Member #3,035
December 2002
|
At once? I thought it could compile only one language at a time . -R |
23yrold3yrold
Member #1,134
March 2001
|
Quote: How do I increase the length of the string? resize(). reserve() is generally worthless. -- |
Neil Walker
Member #210
April 2000
|
Of course, you know I meant separately. But the .NET compiler supports about 20 or so languages at present and you can mix your code if you wish. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
piccolo
Member #3,163
January 2003
|
some times to get strings to work with allegro you need to convert then to a string of chars using the .c-str() example: stringName.c-str() also when you add 2 string the have to be blank or have something in them. example of a blank string : stringName = ""; wow |
Michael Faerber
Member #4,800
July 2004
|
I had problems with Allegro and std::string before, and due to this I always called set_uformat(U_ASCII); once to have Allegro play well with std::string. -- |
Tobias Dammers
Member #2,604
August 2002
|
Quote:
+= should work I think
+= or +. Don't use push_back(), string inherits it from vector; this will append data after the trailing 0, which is not what you want. string s; /* ... */ char c = readkey() & 0xFF; if (c >= 32) s += c; That's it. If it crashes, something else is wrong. --- |
Peter Hull
Member #1,136
March 2001
|
Quote: Don't use push_back(), string inherits it from vector; this will append data after the trailing 0, This is wrong (try it!) #include <string> #include <iostream> using namespace std; int main() { string s; s.push_back('X'); s.push_back('-'); s.push_back('G'); cout << s << endl; return 0; }
Quote: in which case you should use short IIRC). Use wchar_t (string is a typedef for basic_string<char>, wstring is a typedef for basic_string<wchar_t>). Pete
|
ImLeftFooted
Member #3,935
October 2003
|
std::string does not have a trailing '\0'. |
Peter Hull
Member #1,136
March 2001
|
Quote: std::string does not have a trailing '\0'. I thought that too, but I checked in the include file <string> (look at note 3, below).
The relevant part of the standard is 21.3.4. Pete
|
ImLeftFooted
Member #3,935
October 2003
|
Hm, interesting.. |
|
1
2
|