Skip to content

Instantly share code, notes, and snippets.

@myamamic
Created March 13, 2013 04:02
Show Gist options
  • Select an option

  • Save myamamic/5149295 to your computer and use it in GitHub Desktop.

Select an option

Save myamamic/5149295 to your computer and use it in GitHub Desktop.
[debug] printf/printkでNULL終端されてない文字列バッファの中身を出力する
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