fseekプロジェクト

fseek.c

#include <stdio.h>
 
int main(void){
 
  FILE *fp;
  int point;
  int c;
 
  printf("read point:");
  scanf("%d", &point);
 
  if (point >= 0){
 
    fp = fopen("test.txt", "r");
    if (fp == NULL){
        printf("Can't open file!\n");
      return -1;
    }
 
    fseek(fp, point, SEEK_SET);
 
    c = fgetc(fp);
 
    printf("point: %d\n", point);
    printf("char: %c\n", (char)c);
 
  }
 
  return 0;
 
}
 

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2010年07月08日 14:59