Non Printing Characters
-
:((Hi, I've got a code which is adding 2 non-printable characters at the end of the string, which is causing a lot of problem. Can anyone help me in removing these 2 "funny" characters. Here is the code [CODE] ======================================== #include #include #include #include #include using std::string; const char *yy; int u,i; string final = "888808M5359846\n"; void main() { final.append("02/10/2002 14:30:10\n"); yy=final.c_str(); u=strlen(yy); for(i=0;i<=u;i++) { printf("%c %d\n",yy[i],yy[i]); } } =========================================== [CODE] Kindly help!! Many Thanks, John
-
:((Hi, I've got a code which is adding 2 non-printable characters at the end of the string, which is causing a lot of problem. Can anyone help me in removing these 2 "funny" characters. Here is the code [CODE] ======================================== #include #include #include #include #include using std::string; const char *yy; int u,i; string final = "888808M5359846\n"; void main() { final.append("02/10/2002 14:30:10\n"); yy=final.c_str(); u=strlen(yy); for(i=0;i<=u;i++) { printf("%c %d\n",yy[i],yy[i]); } } =========================================== [CODE] Kindly help!! Many Thanks, John
Hello, simply replace for(i=0;i<=u;i++) by for(i=0;i<u;i++) So, remove the =. Then the 2 "funny" characters should not occur. :-D -Dominik
-
Hello, simply replace for(i=0;i<=u;i++) by for(i=0;i<u;i++) So, remove the =. Then the 2 "funny" characters should not occur. :-D -Dominik
Hi Domnik, I did that and its not removed the second character. What comes towards the end is 10 and 0. When I do a for(i=0;i
-
Hi Domnik, I did that and its not removed the second character. What comes towards the end is 10 and 0. When I do a for(i=0;i
You mean the number representation of the linefeed-character? Well, you could count two less than the string-length (CR/LF), or you could introduce a filtering line, that does skip any LF characters. That way you would even skip internal CR/LF sequences. "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert Kaminski
-
Hi Domnik, I did that and its not removed the second character. What comes towards the end is 10 and 0. When I do a for(i=0;i
By the way: C++ like would be doing that with iterators. Its just as easy and less error prone. (see your index error dominic has shown) "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert Kaminski
-
Hi Domnik, I did that and its not removed the second character. What comes towards the end is 10 and 0. When I do a for(i=0;i
As jh pointed out, you have to change the u to u=strlen(yy) - 2; when using CR/LF (\r\n) and u=strlen(yy) - 1; when using LF only (only \n).
-
As jh pointed out, you have to change the u to u=strlen(yy) - 2; when using CR/LF (\r\n) and u=strlen(yy) - 1; when using LF only (only \n).
Hi Dominik and Jh, Yes, your suggestions worked out. Apparently the problem still persists and I've got no clue why its happening.. What I am doing is just sending in some data to another server using a sendto(). The server program is written in Java. But when I send it, the server gets it with some non-printing character (ASCII '0') in the begining and it's causing a problem. Any suggestions, what could be going wrong? Here's the sendto() code [CODE] ======================================== e = sendto(sd,final.c_str(),final.length(),0,(struct sockaddr *)&saServer,sizeof(saServer)); ======================================== [CODE] Many Thanks, John:((
-
Hi Dominik and Jh, Yes, your suggestions worked out. Apparently the problem still persists and I've got no clue why its happening.. What I am doing is just sending in some data to another server using a sendto(). The server program is written in Java. But when I send it, the server gets it with some non-printing character (ASCII '0') in the begining and it's causing a problem. Any suggestions, what could be going wrong? Here's the sendto() code [CODE] ======================================== e = sendto(sd,final.c_str(),final.length(),0,(struct sockaddr *)&saServer,sizeof(saServer)); ======================================== [CODE] Many Thanks, John:((
Hi Dominik and Jh, Just out of curiosity, can we do something like concatenating 2 strings? Something like this in sendto()? ======================== e = sendto(sd,"string1"+"string2",lenght(),0,(struct sockaddr *)&saServer,sizeof(saServer)); ======================== Many Thanks, John