stdio.h 인 _getch() 사용.
sprintf 사용해서 str2를 출력하기도 함.
#define _CRT_SECURE_NO_WARNINGS
#include<time.h>
#include<iostream>
#include<string.h>
#include<Windows.h>
#include <stdio.h>
#include<conio.h>
using namespace std;
int main(void)
{
char str[10];
char str2[10];
int i = 0;
int flag = 0;
while (1)
{
if (0 <= i && i <= 9)
{
char ch = _getch();
str[i] = ch;
++i;
if (i == 9)
{
str[i] = '\0';
flag = 1;
}
}
if (flag == 1)
{
//str 자체 출력.
//cout << str << endl;
/*sprintf 사용해서 출력*/
sprintf(str2, "%s", str);
cout << str2 << endl;
flag = 0;
i = 0;
}
}
return 0;
}'C_C++' 카테고리의 다른 글
| 포인터 활용1(메인함수 내에서 간접참조사용) (0) | 2022.06.30 |
|---|---|
| vector 자료형에 pair, class pointer (0) | 2022.06.30 |
| 벡터와 리스트 차이 (0) | 2022.04.10 |
| 메모리 누수 체크 (0) | 2022.03.27 |
| C 알고리즘 시간 측정방법 (0) | 2021.10.16 |