본문 바로가기 메뉴 바로가기

코딩 잘하고 싶어

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

코딩 잘하고 싶어

검색하기 폼
  • 분류 전체보기 (187)
    • 프론트엔드 (1)
    • 백엔드 및 서버 (17)
    • Java (107)
      • 개념정리 (19)
      • Effective Java (88)
    • C++ (6)
    • OpenCV (1)
    • CS (39)
      • Algorithm (33)
      • 자료구조 (2)
      • 운영체제 (3)
      • 데이터베이스 (1)
    • Unity 게임 (10)
      • Flappy Bird (4)
      • 무한의 계단 (2)
      • 타워 디펜스 (1)
      • Hill Climb Racing (1)
      • RPG (1)
    • 회고 (5)
  • 방명록

c++ istringstream (1)
[ C++ ] stringstream 사용 방법

문자열을 나누는 stringstream C++에서 stringstream은 주어진 문자열에서 필요한 자료형에 맞는 정보를 꺼낼 때 유용하게 사용된다. stringstream에서 공백과 '\n'을 제외하고 문자열에서 맞는 자료형의 정보를 빼낸다. #include 전처리 헤더를 포함해야한다. 예제를 보자! #include #include #include int main() { int num; string s; string str1 = "123 456", str2 = "hello world!"; stringstream stream1, stream2(str2); //초기화 stream1.str(str1); while(stream1 >> num){ cout s){ cout s[1] >> s[2] >> s[3]; }

C++ 2021. 1. 24. 20:12
이전 1 다음
이전 다음
반응형
공지사항
  • 방문해주셔서 감사합니다.
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday

Blog is powered by Tistory / Designed by Tistory

티스토리툴바