[ create a new paste ] login | about

Link: http://codepad.org/je2akZ6u    [ raw code | output | fork ]

C, pasted on Jun 28:
#include<stdio.h>

int main(){
	int num[100];
	int data, i, j;
	FILE* FP;

	//データの個数を入力
	printf("データの個数を入力してください。");
	scanf("%d", &data);

	//読み込み
	FP = fopen("readFile.txt","r");

	for(i=0; i<data; i++){
		fscanf(FP,"%d", &num[i]);
	}
	fclose(FP);

	//書き込み
	FP = fopen("writeFile.txt","w");
	for(i=0; i<data; i++){
		fprintf(FP,"%d ", num[i]);
	}
	fclose(FP);
	return(0);
}


Output:
1
Segmentation fault


Create a new paste based on this one


Comments: