/* 10進整数値のファイル入出力を行うプログラム */
#include <stdio.h>
#define N 10

int main(void)
{
	FILE *fp;
	int i, number[N];

	if( (fp = fopen("num.txt", "w+") ) == NULL) {
		printf("File open error.\n");
		return 1;
	}

	for (i = 1; i <= N; i++) {
		fprintf(fp, "%d ", i);
	}

	fseek(fp, 0L, SEEK_SET);
	for (i = 0; i < N; i++) {
		fscanf(fp, "%d ", &number[i]);
	}

	for (i = 0; i < N; i++) {
		printf("%d ", number[i]);
	}

	fclose(fp);

	return 0;
}
