标签:
//封装ConvertToXXX函数: int ConvertToUpper(char * sInput, char * sNew) { sInput = (char *)strupr(sInput); lr_save_string(sInput,sNew); } int ConvertToLower(char * sInput, char * sNew) { sInput = (char *)strlwr(sInput); lr_save_string(sInput,sNew); } int ConvertToTitle(char * sInput, char * sNew) { int i = 0, s = 0, l = 0; char buf1[50]; char buf2[2]; char n; strncpy(&n,sInput+i,1); sprintf(buf2,"%c",n); strupr(buf2); strcpy(buf1,buf2); i++; while(i < strlen(sInput)) { strncpy(&n,sInput+i,1); sprintf(buf2,"%c",n); if(s == 1){ strupr(buf2); strcat(buf1,buf2); s = 0; } else{ strlwr(buf2); strcat(buf1,buf2); } if(strcmp(" ",buf2)==0) { s = 1; } i++; } lr_save_string(buf1,sNew); }
login() { lr_save_string("testing is believing","str"); ConvertToUpper(lr_eval_string("{str}"),"UpperStr"); lr_output_message(lr_eval_string("{UpperStr}")); ConvertToLower(lr_eval_string("{str}"),"LowerStr"); lr_output_message(lr_eval_string("{LowerStr}")); ConvertToTitle(lr_eval_string("{str}"),"TitleStr"); lr_output_message(lr_eval_string("{TitleStr}"));
标签:
原文地址:http://www.cnblogs.com/qmfsun/p/4575444.html