請採取如下:定義字符串,多行
char buffer[512];
memset(buffer, 0, sizeof(buffer));
sprintf(&buffer[0],"This Is The Longest String In the World that in text goes on and..");
printf("Buffer:%s\r\n",buffer);
我希望能夠創建這種字符串的多行,爲便於故障排除和編輯。但是,當我使用\
命令時,我的輸出被顯示爲標籤的內容分開了?
實施例:
sprintf(&buffer[0],"This Is The\
Longest String In the World\
that in text goes on and..");
產生的輸出:
Buffer:This Is The Longest String In the World that in text goes on and..
任何想法?這只是嘗試在多行代碼中分解字符串的錯誤方法嗎?
你不應該使用'printf' –
'\ r'爲什麼不能在地球上? – Mawg
[如何在C/Objective-C中跨越多行分割字符串文字?](http://stackoverflow.com/questions/797318/how-to-split-a-string-literal-across-multiple -line-in-c-objective-c) –