using System;
class program {
private static void Main(string[] args) {
int c;
int cnt = 0;
while ((c = Console.Read()) != -1 ) {
cnt++;
Console.Write( (char) c );
}
Console.Write( "\n" + cnt + " characters read.\n");
}
}
---- 다음은 string 변수를 사용한 약간 다른 방법이다.
using System;
class program {
private static void Main(string[] args) {
int c;
string s = "";
while ((c = Console.Read()) != -1 ) {
s = s + (char) c;
}
Console.Write( s );
}
}
'C# 언어' 카테고리의 다른 글
| C# 파일 읽기와 쓰기 (0) | 2023.02.12 |
|---|---|
| C# reading from stdin using readline function (1) | 2022.06.20 |
| C#으로 메모장(Notepad) 만들기 (1) | 2021.09.19 |
| C# Windows Forms 항상 닫히지 않게 하기 (0) | 2021.09.19 |
| C#으로 만든 스티커 메모 (소스코드 없음) (0) | 2021.09.19 |
댓글