0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

C言語ファイル出力

Last updated at Posted at 2020-09-06

ファイル出力すだけの関数、テストのファイル作る時に使うかも。

test.c
# include <stdio.h>
# define PROC_OK (0)
# define  PROC_NG (-1)

int SaveFileData(char *file_name,int data_cnt)
{
	FILE *fp = NULL;
	
	if ((fp = fopen(file_name, "w")) == NULL) {
		/* エラー */
		return PROC_NG;
	}
	
	for(int cnt=1;cnt<=data_cnt;++cnt)
	{
		fprintf(fp, "%08d", cnt);
		if(cnt > 0 && (cnt % 10 == 0) )
		fprintf(fp, "\n");
	}
	
	fclose(fp);
	return PROC_OK;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?