Server Help

General Questions - Biller Coding Yay

Contempt+ - Wed Oct 29, 2008 12:17 am
Post subject: Biller Coding Yay
error C2679: binary '+=' : no operator defined which takes a right-hand operand of type 'unsigned char [32]'

Trying to do:
Code: Show/Hide
s += player->player->Name;

And i get the error above.

What i'm trying to do is change the ?login on CatID's biller so that it says:
Login successful. Welcome back <username>. So in my case, Welcome back Contempt+.
Cheese - Wed Oct 29, 2008 12:29 am
Post subject:
1st glance,
player->name instead of
player->player->name?


or perhaps you cant strcat strings with +...
your compiler wouldnt allow it

like A + E != AE
Contempt+ - Wed Oct 29, 2008 12:41 am
Post subject:
I'm using MSVC 6.0.. And player->Name doesn't exist.
Samapico - Wed Oct 29, 2008 1:07 am
Post subject:
You can't use += with a char array...
Nothing to do with the compiler, but more with the language itself.
It works in MervBot when you use the String class, but it never works with char[]
You need to use strcat(char *, char *)
google some for help on it. But basically, one of the arguments is const, which is the string you want appended, and the other one is the string to which you want to append stuff
strcat(s, player->player->Name);
or something like that
Contempt+ - Wed Oct 29, 2008 1:17 am
Post subject:
So pretty much, just make the whole string strcat?

EDIT: There's no other way to do it?
Dr Brain - Wed Oct 29, 2008 6:12 am
Post subject:
Contempt+ wrote:
EDIT: There's no other way to do it?


It's C++, there's a billion ways to do anything. Using strcat is just the most direct.
Contempt+ - Wed Oct 29, 2008 12:44 pm
Post subject:
Hmm, I'm a newbie with coding. Anyone have a link or a reference I can look at so I can implement it?
Samapico - Wed Oct 29, 2008 1:10 pm
Post subject:
http://en.wikipedia.org/wiki/Strcat

Quote:
The name strcat is an abbreviation of "string concatenate". strcat is found in the string.h header file.
Make sure to include it
Contempt+ - Wed Oct 29, 2008 1:28 pm
Post subject:
Well, the biller uses strings all throughout the src, so string.h is in the header.

Only problem is, my dumb ass can't figure it out haha.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group