//#include <windows.h> // (Windows)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> // (Linux)
// 表示器
void display_machine(char *d, int len_disp_moji, int len_buff)
{
char c;
int i;
// 表示文字数分だけ表示
for (i = 0; i < len_disp_moji; i++) {
}
// ・左スライド
// ・あふれる文字を(表示文字の長さ+表示器の長さ-1の)バッファの最後端に移動
c = d[0];
d[len_buff - 1] = c;
}
// main
int main()
{
char *buff; // 表示文字の長さ+表示器の長さ-1のバッファ
int i;
char ch_sp; // 空白の文字
char *h_moji; // 表示文字
int len_m; // 表示文字の長さ
int len_h; // 表示器の長さ
int n; // スライド回数
h_moji = "Hello";
ch_sp = '*';
len_h = 10;
n = 100;
buff
= (char *) malloc(len_m
+ len_h
- 1); memset(buff
, ch_sp
, len_m
+ len_h
- 1); for (i = 0; i < n; i++) {
display_machine(buff, len_h, len_m + len_h - 1);
sleep(1); // 1秒ウェイト (Linux)
//Sleep(1000); // 1秒ウェイト (Windows)
}
return 0;
}
Ly8jaW5jbHVkZSA8d2luZG93cy5oPiAgICAgICAgICAgIC8vIChXaW5kb3dzKQojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4gICAgICAgICAgICAgLy8gKExpbnV4KQoKLy8g6KGo56S65ZmoCnZvaWQgZGlzcGxheV9tYWNoaW5lKGNoYXIgKmQsIGludCBsZW5fZGlzcF9tb2ppLCBpbnQgbGVuX2J1ZmYpCnsKICAgIGNoYXIgYzsKICAgIGludCBpOwoKICAgIC8vIOihqOekuuaWh+Wtl+aVsOWIhuOBoOOBkeihqOekugogICAgZnByaW50ZihzdGRlcnIsICJcciIpOwogICAgZm9yIChpID0gMDsgaSA8IGxlbl9kaXNwX21vamk7IGkrKykgewogICAgICAgIGZwcmludGYoc3RkZXJyLCAiJWMiLCBkW2ldKTsKICAgIH0KICAgIC8vIOODu+W3puOCueODqeOCpOODiQogICAgLy8g44O744GC44G144KM44KL5paH5a2X44KSKOihqOekuuaWh+Wtl+OBrumVt+OBlSvooajnpLrlmajjga7plbfjgZUtMeOBrinjg5Djg4Pjg5XjgqHjga7mnIDlvoznq6/jgavnp7vli5UKICAgIGMgPSBkWzBdOwogICAgbWVtbW92ZShkLCBkICsgMSwgbGVuX2J1ZmYgLSAxKTsKICAgIGRbbGVuX2J1ZmYgLSAxXSA9IGM7Cn0KCi8vICAgICAgbWFpbgppbnQgbWFpbigpCnsKICAgIGNoYXIgKmJ1ZmY7ICAgICAgICAgICAgICAgICAvLyDooajnpLrmloflrZfjga7plbfjgZUr6KGo56S65Zmo44Gu6ZW344GVLTHjga7jg5Djg4Pjg5XjgqEKICAgIGludCBpOwogICAgY2hhciBjaF9zcDsgICAgICAgICAgICAgICAgIC8vIOepuueZveOBruaWh+WtlwogICAgY2hhciAqaF9tb2ppOyAgICAgICAgICAgICAgIC8vIOihqOekuuaWh+WtlwogICAgaW50IGxlbl9tOyAgICAgICAgICAgICAgICAgIC8vIOihqOekuuaWh+Wtl+OBrumVt+OBlQogICAgaW50IGxlbl9oOyAgICAgICAgICAgICAgICAgIC8vIOihqOekuuWZqOOBrumVt+OBlQogICAgaW50IG47ICAgICAgICAgICAgICAgICAgICAgIC8vIOOCueODqeOCpOODieWbnuaVsAoKICAgIGhfbW9qaSA9ICJIZWxsbyI7CiAgICBjaF9zcCA9ICcqJzsKICAgIGxlbl9oID0gMTA7CiAgICBsZW5fbSA9IHN0cmxlbihoX21vamkpOwogICAgbiA9IDEwMDsKICAgIGJ1ZmYgPSAoY2hhciAqKSBtYWxsb2MobGVuX20gKyBsZW5faCAtIDEpOwogICAgbWVtc2V0KGJ1ZmYsIGNoX3NwLCBsZW5fbSArIGxlbl9oIC0gMSk7CiAgICBtZW1tb3ZlKGJ1ZmYsIGhfbW9qaSwgbGVuX20pOwogICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgIGRpc3BsYXlfbWFjaGluZShidWZmLCBsZW5faCwgbGVuX20gKyBsZW5faCAtIDEpOwogICAgICAgIHNsZWVwKDEpOyAgICAgICAgICAgICAgIC8vIDHnp5LjgqbjgqfjgqTjg4ggKExpbnV4KQogICAgICAgIC8vU2xlZXAoMTAwMCk7ICAgICAgICAgICAgLy8gMeenkuOCpuOCp+OCpOODiCAoV2luZG93cykKICAgIH0KICAgIGZyZWUoYnVmZik7CgogICAgcmV0dXJuIDA7Cn0K