程序员家园论坛软件开发C++ Builder编程技术 新手请教:BCB中如何实现对文本文件的整行整行的读??????

1  /  1  页   1 跳转 查看:475

新手请教:BCB中如何实现对文本文件的整行整行的读??????

新手请教:BCB中如何实现对文本文件的整行整行的读??????

高手赐教
 

回复:新手请教:BCB中如何实现对文本文件的整行整行的读??????

#include <string.h>
#include <stdio.h>

int main(void)
{
  FILE *stream;
  char msg[] = "this is a test";
  char buf[20];

  if ((stream = fopen("DUMMY.FIL", "w+"))
      == NULL)
  {
      fprintf(stderr, "Cannot open output file.\n");
      return 1;
  }

  /* write some data to the file */
  fwrite(msg, strlen(msg)+1, 1, stream);

  /* seek to the beginning of the file */
  fseek(stream, SEEK_SET, 0);

  /* read the data and display it */

  fread(buf, strlen(msg)+1, 1, stream);
  printf("%s\n", buf);

  fclose(stream);
  return 0;
}
小鱼是我永远的好学生,老师相信小鱼永远是最棒的,只比狼子差一点点!
                              ---------------三草老师
 

回复: 新手请教:BCB中如何实现对文本文件的整行整行的读??????

thank you very much!!!
 

回复:新手请教:BCB中如何实现对文本文件的整行整行的读??????

Not at all.
小鱼是我永远的好学生,老师相信小鱼永远是最棒的,只比狼子差一点点!
                              ---------------三草老师
 
1  /  1  页   1 跳转

版权所有 程序员家园论坛   Sitemap

Powered by Discuz!NT 2.1.202    Copyright © 2001-2008 Comsenz Inc.
Processed in 0.03125 second(s) , 3 queries. 浙ICP备07502118号
返顶部