Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

파일 입출력 3

From ZeroWiki
#include <iostream>
using namespace std;

int main()
{
	int a,b,c;
	char str[100];
	printf("a = ");
	scanf( "%d", &a );
	printf("b = ");
	scanf( "%d", &b );
	printf("c = ");
	scanf( "%d", &c );
	printf("Input filename : ");
	scanf( "%s", str);
	
	//FIlE 열기 전에 입력 받아야 함 

	FILE *fpt_1;    
	fpt_1 = fopen( str, "w");	

	fprintf( fpt_1, "a = %d \nb = %d \nc = %d", a,b,c); //printf와 사용법 비슷 
    
	fclose(fpt_1);                      
	system("pause");
	return 0;

}