這不是字符串的長度就是你的問題,它是特殊字符處理。
Best to run your string through a converter (to add escape codes),
there are quite a few characters that input does not like:
<pre>
() < > | ; & * \ ~
</pre>
and space escaped with %s .
<pre>
char * convert(char * trans_string)
{
char *s0 = replace(trans_string, '\\', "\\\\");
free(trans_string);
char *s = replace(s0, '%', "\\\%");
free(s0);
char *s1 = replace(s, ' ', "%s");//special case for SPACE
free(s);
char *s2 = replace(s1, '\"', "\\\"");
free(s1);
char *s3 = replace(s2, '\'', "\\\'");
free(s2);
char *s4 = replace(s3, '\(', "\\\(");
free(s3);
char *s5 = replace(s4, '\)', "\\\)");
free(s4);
char *s6 = replace(s5, '\&', "\\\&");
free(s5);
char *s7 = replace(s6, '\<', "\\\<");
free(s6);
char *s8 = replace(s7, '\>', "\\\>");
free(s7);
char *s9 = replace(s8, '\;', "\\\;");
free(s8);
char *s10 = replace(s9, '\*', "\\\*");
free(s9);
char *s11 = replace(s10, '\|', "\\\|");
free(s10);
char *s12 = replace(s11, '\~', "\\\~");
//this if un-escaped gives current directory !
free(s11);
char *s13 = replace(s12, '\¬', "\\\¬");
free(s12);
char *s14 = replace(s13, '\`', "\\\`");
free(s13);
// char *s15 = replace(s14, '\¦', "\\\¦");
// free(s14);
return s14;
}
(code from inputer native binary: interactive converter for input).
確保您的文本字符串不包含空格。用'%s'替換所有空格 –
Yea已經這樣做了。那麼我想出了一個臨時和簡單的解決方案,通過輸入3部分,並且字符串只是追加一個部分到另一個 – user3189761