"C++ cin"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
4번째 줄: 4번째 줄:


{{소스헤더|a.cpp}}
{{소스헤더|a.cpp}}
<source lang='cpp'>
<syntaxhighlight lang='cpp'>
#include <iostream>
#include <iostream>
using namespace std;
using namespace std;
16번째 줄: 16번째 줄:
   return 0;
   return 0;
}
}
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
jmnote@zetawiki:~$ g++ a.cpp
jmnote@zetawiki:~$ g++ a.cpp
jmnote@zetawiki:~$ ./a.out
jmnote@zetawiki:~$ ./a.out
Please enter your name: ABC
Please enter your name: ABC
Hello, ABC!
Hello, ABC!
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
jmnote@zetawiki:~$ g++ a.cpp
jmnote@zetawiki:~$ g++ a.cpp
jmnote@zetawiki:~$ ./a.out
jmnote@zetawiki:~$ ./a.out
Please enter your name: ABC
Please enter your name: ABC
Hello, ABC!
Hello, ABC!
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
jmnote@zetawiki:~$ echo JohnSmith | ./a.out  
jmnote@zetawiki:~$ echo JohnSmith | ./a.out  
Please enter your name: Hello, JohnSmith!
Please enter your name: Hello, JohnSmith!
jmnote@zetawiki:~$ echo John Smith | ./a.out  
jmnote@zetawiki:~$ echo John Smith | ./a.out  
Please enter your name: Hello, John!
Please enter your name: Hello, John!
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:47 기준 최신판

1 개요[ | ]

C++ cin
  • 표준입력스트림
a.cpp
#include <iostream>
using namespace std;

int main ()
{
  char name[40];
  cout << "Please enter your name: ";
  cin >> name;
  cout << "Hello, " << name << "!" << endl;
  return 0;
}
jmnote@zetawiki:~$ g++ a.cpp
jmnote@zetawiki:~$ ./a.out
Please enter your name: ABC
Hello, ABC!
jmnote@zetawiki:~$ g++ a.cpp
jmnote@zetawiki:~$ ./a.out
Please enter your name: ABC
Hello, ABC!
jmnote@zetawiki:~$ echo JohnSmith | ./a.out 
Please enter your name: Hello, JohnSmith!
jmnote@zetawiki:~$ echo John Smith | ./a.out 
Please enter your name: Hello, John!

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}