This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 »
541
Announcements / Re: Another choice.
« on: March 16, 2010, 06:51:20 pm »Also, I'd really like to see an English->French translator hard coded over the two languages' twelve similarities.You mean not like Google translator!?!?
Where one person can suggest a translation and it becomes completely inaccurate!?
542
Announcements / Re: Another choice.
« on: March 15, 2010, 08:48:42 pm »
Why not use ++ and -- instead of +=1 and -=1?
543
Announcements / Re: Quick Poll
« on: March 14, 2010, 04:44:34 pm »
I never make semicolon mistakes on anything but struct or class. :/
The GCC gives good enough syntax error reporting to not have to worry about it.
The GCC gives good enough syntax error reporting to not have to worry about it.
544
Announcements / Re: Quick Poll
« on: March 14, 2010, 02:42:10 pm »
GM treats var x,y as bad syntax without a semicolon; the same should apply to struct and class.
545
Tips, Tutorials, Examples / Re: lol streams
« on: March 06, 2010, 03:25:17 pm »546
Tips, Tutorials, Examples / Re: lol streams
« on: March 05, 2010, 10:04:53 pm »The only difference between const char* and char* is that const char* points to read-only memory. And even that's only on systems that support such (ie, not Windows). '\0' == 0, and I'd be willing to bet that if you were to compare {'n','o',0} and "no" you'd get that they were equivalent. And I do mean as-is.Whenever I have tried to do it without const_cast, G++ bugs me about a depreciated conversion (that works). I always use -Wall and purge all warnings and errors, and that is one that I happen to get into the habit of doing.
"Test" == "test" compares correctly for string literals. "Test" == "test" will return false, "test" == "test" will return true. This is because they point to the same location in memory when GCC is done with them.
Also, you don't need to use const_cast to get it represented as a const char.
Const char* can be set to a char* without cast. Vice-versa requires cast, but is dangerous on Linux and the like.
548
Tips, Tutorials, Examples / Re: lol streams
« on: March 05, 2010, 09:30:16 pm »
Erm, why would you want to do that? That's kind of the point of string - to add things like that.
549
Tips, Tutorials, Examples / Re: lol streams
« on: March 04, 2010, 09:19:37 pm »Could you implement those operators for char *s?string operator+(string str,char *str2)
{
return str+const_cast<const char*>(str2);
}
?
550
Tips, Tutorials, Examples / Re: lol streams
« on: March 04, 2010, 07:23:09 pm »Those functions are on cplusplus.com:I was looking at <cstring>; for whatever reason, it didn't occur to me to look at <string>.
http://cplusplus.com/reference/string/operator+/
http://cplusplus.com/reference/string/operators/
551
Tips, Tutorials, Examples / Re: lol streams
« on: March 04, 2010, 06:52:23 pm »
I hate it when cplusplus.com doesn't provide an accurate reference.
I learned something new, today, I guess.
I learned something new, today, I guess.
552
Tips, Tutorials, Examples / Re: lol streams
« on: March 04, 2010, 06:38:54 pm »
Additionally, here's something else that might be useful:
Simple operators for strings.
Code: [Select]
// Operators for strings (addition)
string &operator +(string &str1,string &str2)
{
string temp=str1;
return temp+=str2;
}
string &operator +(string &str1,cstring str2)
{
string temp=str1;
return temp+=str2;
}
// Operators for strings (comparison)
bool operator ==(string &str1,string &str2)
{
string temp=str1;
return (temp.compare(str2));
}
bool operator ==(string &str1,cstring str2)
{
string temp=str1;
return (temp.compare(str2));
}
// Operators for strings (comparison)
bool operator !=(string &str1,string &str2)
{
return !(str1==str2);
}
bool operator !=(string &str1,cstring str2)
{
return !(str1==str2);
}
Simple operators for strings.
553
Announcements / Re: Pride
« on: March 04, 2010, 06:33:57 pm »
To be honest, I've completely forgotten about goto. :/
554
Announcements / Re: Pride
« on: March 04, 2010, 06:09:54 pm »
With that hash, wouldn't "hello" and "herro" be considered two identical strings? What does it check besides the length and first and last characters?
555
Announcements / Re: Encryption
« on: March 02, 2010, 08:44:22 pm »I think that your statement seems to be in reverse.most of us could care less about encryptionI think that most of us couldn't care less. If we could care less, we would care at least some.