C/C++の宿題片付けます 128代目at TECH
C/C++の宿題片付けます 128代目 - 暇つぶし2ch902:デフォルトの名無しさん
09/07/10 23:51:59
>>827
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#define SLEEP_TIME 1
int main(int argc, char *argv[])
{
  struct stat file;
  time_t prev_mtime;
  if (argc != 2) {
    printf("Usage: exp7 file1 file2\n");
    exit(1);
  }
  if (stat(argv[1], &file) != 0) {
    printf("%s not found\n", argv[1]);
    exit(1);
  }
  prev_mtime = file.st_mtime;
  while (1) {
    stat(argv[1], &file);
    if (file.st_mtime != prev_mtime) {
      printf("\nModified %s %s", argv[1],
        asctime(localtime(&file.st_mtime)));
      prev_mtime = file.st_mtime;
    }
    sleep(SLEEP_TIME);
  }
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch