C++ 문자열 공백 포함 입력받기
cin.getline(s, n, delim); 공백과 종료(NULL)을 포함하여 n만큼 입력받아 s에 저장 delim문자가 입력되면 종료 @ 인자값 s : 문자열을 입력받으려는 문자배열 n : s에 입력받으려는 최대 문자수(공백과 NULL문자 포함) delim : 해당 문자가 나타나면 입력 종료('\n') #include using namespace std; #define MAX 1000000 int main() { char* s = new char[MAX]; cin.getline(s, MAX, '\n'); cout
프로그래밍/C,C++
2019. 7. 29. 03:45
C++ 파일 입출력 1.
@ 파일전체를 한번에 출력하기(위치 지정자 사용) >> #include #include #include using namespace std; int main() { ifstream theFile("players.txt"); string s; if (theFile.is_open()) { theFile.seekg(0, ios::end); // 위치 지정자를 파일 끝으로 옮기기 int size = theFile.tellg(); // 가져오려는 파일의 크기구하기 s.resize(size); // 구한 크기를 s에 할당하기 theFile.seekg(0, ios::beg); // 위치 지정자를 파일 맨맢으로 옮기기 theFile.read(&s[0], size); // 파일 전체내용을 읽어서 문자열에 저장 cout
프로그래밍/C,C++
2019. 7. 29. 03:40
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 문자열입력
- 커널
- 단어의 개수
- toy cipher
- stringstream
- ??!
- 토이사이퍼
- getline()
- 파일입출력
- C++
- cin.getline()
- 자료구조
- to_string
- 백준알고리즘
- 1152
- 알고리즘
- boj
- 웹 서버
- 데이터저장장치
- Web Server
- 네트워크결합스토리지
- web application server
- 운영체제
- 쉘
- 정수
- 25083
- 백준
- 정수를 문자열로
- 트리만들기
- 웹 어플리케이션 서버
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함