Converting to lower case errors
#1

Hey, I have some errors and warnings regarding to this function:
Code:
21: CorrectCaps(const string[],dest[]="",len=0)
22: {
23:  	for(new i=1;i<strlen(string);i++)
24:		if(string[i]>64 && string[i]<94)
25:			string[i]+=32;
26:	dest[0]=EOS;
27:	strcat(dest,string,len);
28:	return string;
29: }
The errors:
Code:
(25) : error 022: must be lvalue (non-constant)
(25) : warning 217: loose indentation
(25) : error 017: undefined symbol "i"
(25) : warning 215: expression has no effect
(26) : warning 217: loose indentation
Reply
#2

Quote:
Originally Posted by Davi52
View Post
Hey, I have some errors and warnings regarding to this function:
Code:
21: CorrectCaps(const string[],dest[]="",len=0)
22: {
23:  	for(new i=1;i<strlen(string);i++)
24:		if(string[i]>64 && string[i]<94)
25:			string[i]+=32;
26:	dest[0]=EOS;
27:	strcat(dest,string,len);
28:	return string;
29: }
The errors:
Code:
(25) : error 022: must be lvalue (non-constant)
(25) : warning 217: loose indentation
(25) : error 017: undefined symbol "i"
(25) : warning 215: expression has no effect
(26) : warning 217: loose indentation
Possibly something to do with on this line:
Code:
CorrectCaps(const string[],dest[]="",len=0)
Perhaps it should be like this?:
Code:
CorrectCaps(const string[],dest[],len=0)
Reply
#3

You modify `string` so it cannot be a const array. Also functions may not return arrays of unknown size. Last, you can store what `strlen` returns in a variable to avoid calling the function over and over again.
Reply
#4

Is there not a "tolower" method that you can call?
Reply
#5

Just wondering if you know this function or not. If you do, ignore this message. If you don't:
https://sampwiki.blast.hk/wiki/tolower
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)