본문 바로가기

영넌 개발로그

검색하기
영넌 개발로그
프로필사진 영넌

  • 분류 전체보기 (71)
    • 설치 (6)
    • 코딩 (60)
      • C++ (44)
      • python (1)
      • ML , Deep (13)
      • 캐글 (0)
    • 알고리즘 연습 (5)
      • 이론 (5)
      • python 프로그래머스 (0)
Guestbook
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록파일 쓰기 (2)

영넌 개발로그

[C++ File] fstream I/O (ofstream, ifstream)

파일을 이용한 input, output을 작성해보자 헤더는 #include 이 필요하다. 파일을 읽을 때는 ifistream 클래스, 파일을 쓸 때는 ofstream 클래스를 사용해도 된다. fstream 클래스의 f라는 객체를 만들어 0~9 까지 숫자를 쓰는 코드이다. 읽거나 쓰는 것에 대한 모드를 지정해주어야한다. 이는 std::ios::out 이나 std::ios::in 으로 작성한다. 파일 쓰기> #include #include using namespace std; int main() { fstream f("test_1.txt", ios::out); if (!f) { cout

코딩/C++ 2020. 12. 6. 06:39
[C++ 기초] text file 읽고 쓰기, fstream 헤더

File 1. binaryfile : (mp3 ...) 2. text file : 노트패드로 열었을 때 사람의 눈으로 알기 쉽게 보이는 파일 (cpp, txt ...) 파일 쓰기 ofstream output file ofstream outFile; ofstream이 하나의 데이터형 (class) outFile.open('text.txt') 열고 쓰기 outFile.close() 닫아야 제대로 기록이 남아있음 예제 실행코드> #define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; int main() { ofstream outFile; outFile.open("yyy.txt"); //사람 이름, 나이, 체중 cout

코딩/C++ 2020. 10. 23. 17:39
Prev 1 Next

Blog is powered by kakao / Designed by Tistory

티스토리툴바