未分類

c言語 ターミナル上で出力した文字列の表示を初期化する

投稿日:2020年11月27日 更新日:

エスケープシーケンス \033[2J と\033[u を使う。

#include <unistd.h>
#include <stdio.h>

int main()
{
int i = 0;
while (true)
{
i++;
printf("\033[2J\033[ui = %d\n",i);
usleep(1000);
}

return 0;
}

結果

i = 1117

のような出力が出続ける。

-未分類
-

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

tex で同値記号(⇔)を入力する方法

同値記号を入力するには、\Leftrightarrow を使う。 例 $b \leftrightarrow c$, $b \Leftrightarrow c$

no image

python3 で文字列のリストを結合する方法

list に対して、extend を使う。 例 list1 = [1,2,3] list2 = [4,5,6] list1.extend(list2) print(list1) 結果 [1, 2, 3 …

no image

mac の convert コマンドで画像ファイルをサイズ変更する

convert コマンドを使うには、imagemagick というソフトがインストールされていることが必要。 インストールの確認 $ which convert で、imagemagick がインスト …

no image

tex で差集合の記号を入力する方法

\setminus を使う。 例 $A \setminus B$ 結果

no image

python3 で、文字列の最後が特定の文字で終わるか判定する方法

endswith を使う。 例 str1 = “こんにちは” result1 = str1.endswith(“は”) result2 = str1.endswith(“わ”) print(resul …