Friends
I want to integrate the following code into the main application code. The junk characters that come populated with the o/p string dumps the application The following code snipette doesnt work..
void stringCheck(char*); int main() { char some_str[] = 'Common Application FE LBS Serverr is down'; stringCheck(some_str); } void stringCheck(char * newString) { for(int i=0;i<strlen(newString);i++) { if ((int)newString[i] >128) { TRACE(' JUNK Characters in Application Error message FROM DCE IS = '<<(char)newString[i]<<'++++++'<<(int)newString[i]); } } }
Can someone please show me the better approaches to find junk characters in a string..
Many Thanks
Your
charprobably is represented signed. Cast it tounsigned charinstead to avoid that it becomes a negative integer when casting toint:Depending on your needs,
isprintmight do a better job, checking for a printable character, including space:Note that you have to cast to
unsigned char: input forisprintrequires values between0andUCHAR_MAXas character values.