私は\bエスケープシーケンスの機能を理解しようとしている次のプログラムを持っています。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int disp(char *a)
{
return printf("%s", a);
}
int main(void)
{
char *s = "Hello\b\b";
printf(" %d\n", disp(s));
printf("%s %d\n", s, strlen(s));
return 0;
}
出力:
$ ./a.out
Hel 7
Hel 7
$
期待どおりにHello\b\b印刷されますが、2文字を含む7Hellがstrlen()返されます。\b
C99に従って、5.2.2\bは次のように定義されます。
\b (backspace) Moves the active position to the
previous position on the current line. If the
active position is at the initial position of
a line, the behavior of the display device is
unspecified.
のような文字列関連の関数ではどのように\b解釈されますstrlen()か?\bおよびその他のエスケープシーケンスは、コンパイル時または実行時に解決されますか?