=== in C++ === {{{~cpp #include using namespace std; int main() { ifstream fin("input.txt"); // fin과 input.txt를 연결 ofstream fout("output.txt"); // fout과 output.txt를 연결 int a,b; fin >> a >> b; // cin으로 화면에서 입력받는다면, fin은 연결된 파일로부터 입력받는다. fout << a+b << endl; // cout으로 화면으로 출력한다면, fout은 연결된 output.txt에 a+b를 출력 return 0; } }}} input.txt {{{~cpp 3 8 }}} 저 프로그램을 실행하면 output.txt가 생기면서 11이 그 안에 써진다. === Python === {{{~cpp fin = file('input.txt') fout = file('output.txt.','w') a,b=[int(i) for i in fin.read().split()] print >> fout,(a+b) #혹은 fout.writeline( str(a+b)+'n' ) fin.close() fout.close() }}} input.txt {{{~cpp 3 8 }}} 저 프로그램을 실행하면 output.txt가 생기면서 11이 그 안에 써진다. === Java === {{{~cpp try { String inputString; InputStreamReader isr = new InputStreamReader(new FileInputStream(fileName)); BufferedReader br = new BufferedReader(isr); while((inputString = br.readLine()) != null) { buf = buf + inputString ; buf = buf + "r" ; buf = buf + "n" ; {} br.close(); } catch (IOException e) System.out.println("Error : "+ e.toString()); {} }}} ["JavaStudy2002/입출력관련문제"] ---- [프로그래밍분류]