未分類

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 で行列の省略した部分を書く方法

斜めの点列を \ddots として書くのがコツ。\matrix を使うためにパッケージ amsmath を使う。 例 \usepackage{amsmath} \begin{document} $$ …

no image

tex で かけ算の中点を入力する方法

かけ算に使うような中点を入力するには、 $cdot$ を使う。 例 $a = b \cdot c$ 結果

no image

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

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

no image

tex で和集合を入力する方法

\bigcup を使う。 例 $\displaystyle \bigcup _ {i \in \Lambda} A_i $ 結果

no image

python3 で、ファイルの文字列の1行目を出力する

ファイルを読み込んで、1行目だけをコンソールに出力するには readlines() を使う。 例 f = open(“data.txt”) lines = f.readlines() print(li …