[ create a new paste ] login | about

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

C, pasted on Dec 26:
#include <stdio.h>

int main(void)
{
	int p;
	FILE *cfPtr;

	if( ( cfPtr = fopen("sample1.txt", "w")) == NULL) 
		printf("ファイルをオープンできませんでした");
	else {
		printf("整数を半角で入力してください\n");
		printf("EOF(Ctrl+z)を入力すると終了します\n");
		scanf("%d", &p);

		while( !feof( stdin) ) {
			fprintf(cfPtr, "%d\n", p);
			scanf("%d", &p);
		}

		fclose( cfPtr);
	}
	return 0;
}


Output:
1
ファイルをオープンできませんでした


Create a new paste based on this one


Comments: