프로그램을 실행하면, 1부터 10까지를 c:\my.txt 에 저장하고 system("notepad c:\mytxt"); 를 실행하여 출력되도록 하세요. 오류가 있는 경우 #include <stdlib.h>를 포함하세요.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
FILE *fp;
fp=fopen("C:\\my.txt","w");
for(int i=1; i<11; i++)
{
fprintf(fp,"%d\n",i);
}
fclose(fp);
system("notepad c:\\my.txt");
return 0;
}
'프로그래밍 > C++' 카테고리의 다른 글
예외처리 예제 (0) | 2012.02.24 |
---|---|
예외처리 (0) | 2012.02.24 |
오버라이딩 예제 (0) | 2012.02.24 |
클래스에 데이터를 저장하고 가져와서 출력하기 (0) | 2012.02.24 |
private 변수값 초기화 하기 (0) | 2012.02.24 |