v0id Report post Posted April 24, 2006 I'm not sure if this is the correct place to post this, and it may be frowned upon, but for those of you that have created a bot with redknight... I've ran into this problem while compiling in DEV-C++ 4.9.9.2 in elbot.c elbot.c: In function `process_text_message': elbot.c:250: error: assignment of read-only location Line250 data = tolower(data); ERROR : assignment of read-only location data is declared like this: Line240 void process_text_message(const char *data, int PM) { --------------- If anyone could shed some light, I would appreciate it -- otherwise, I'm sure I'll figure it out in a few. But a quickfix from someone that has done it before would be great!! Thanks in advance! Share this post Link to post Share on other sites
Bongo Report post Posted April 24, 2006 You can't change a variable that's declared with the "const" keyword. Either remove it or create a pointer to data like so: char *p = data; then... p[i] = tolower(p[i]) would not cause an error. Share this post Link to post Share on other sites
v0id Report post Posted April 24, 2006 (edited) You can't change a variable that's declared with the "const" keyword. Either remove it or create a pointer to data like so: char *p = data; then... p[i] = tolower(p[i]) would not cause an error. Yep! that worked. ...among fixing other things... lol. well, at least this gives me a template to work from. now the real fun begins. Thanks for the pointer (no pun intended)! Edited April 24, 2006 by v0id Share this post Link to post Share on other sites
crusadingknight Report post Posted April 25, 2006 (edited) I'm not sure if this is the correct place to post this, and it may be frowned upon, but for those of you that have created a bot with redknight... I wouldn't recommend it, unless you need a guard bot. The source is a bit of a mess, though I'm slowly tacking on some proper architecture, and deadheading the worst of it (ie. I have, though not yet committed, the code to move from the weird old hacked lists architecture to a proper hash list format.) Still, in the interim... storebot may be the better choice. (Which, I believe, is based almost entirely off of Bongo's work.). Edited April 25, 2006 by crusadingknight Share this post Link to post Share on other sites
Bongo Report post Posted April 25, 2006 Which, I believe, is based almost entirely off of Bongo's work. No need to give me credit for that monstrosity :-). I abandoned that project shortly after starting it. If you're looking for a decent store bot, look no further than somewhere else. Share this post Link to post Share on other sites
trollson Report post Posted May 2, 2006 You can't change a variable that's declared with the "const" keyword. Either remove it or create a pointer to data like so: char *p = data; then... p[i] = tolower(p[i]) would not cause an error. However it may cause a SEGV later. You don't know where 'data' came from, and cannot make presumptions. It may point to read-only memory, such as a string literal. eg: const char *data = "Hello World"; These are now placed in read-only memory, and attempting to change them will result in a runtime error/crash/SEGV. You cannot cast away your problems, you are just hiding the bug for later. Options are: Change the function declaration. This is bad because it requires all users to re-evaluate their use of it, but is necessary if the side-effect of calling this function is to lower-case the contents of 'data'. Or take a local mutable copy of the data and use that instead. In which case the case changes will not be passed out of the function. Share this post Link to post Share on other sites