Created
March 13, 2013 04:02
-
-
Save myamamic/5149295 to your computer and use it in GitHub Desktop.
[debug] printf/printkでNULL終端されてない文字列バッファの中身を出力する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NULL終端されていない文字列が格納されたバッファがあり、文字列の長さが分かっているときに、 | |
| printf/printkで簡単に文字列を出力する方法。 | |
| 文字列バッファのポインタをstr | |
| 実際に格納されている文字列の長さをstrlen とする。 | |
| // strlen分だけstrから読み込む | |
| printf(“文字列の中身は=%.*s”, strlen, str); | |
| 動作確認:gcc 4.4.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment