-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHW51.cpp
64 lines (61 loc) · 1.27 KB
/
HW51.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<stdio.h>
#include<string.h>
#include<windows.h>
#pragma warning (disable : 4996)
void inputString(const char*, char*); // 문자열 입력 함수
void gotoxy(int, int); // 커서 이동함수
void printString(char*); // 화면에 문자열 출력
void scroll(char*, int); // 문자열 좌측으로 한칸 스크롤 시키는 함수
int main()
{
char string[50];
inputString("문자열을 입력하시오 : ", string);
printString(string);
return 0;
}
void inputString(const char* msg, char* string)
{
printf("%s",msg);
fgets(string, 50,stdin);
}
void printString(char* string)
{
int strlen = 0;
for (int i = 0; i < 50; i++){
if (string[i] == '\n') { break; }
strlen++;
}
system("cls");
gotoxy(30, 12);
printf("%s", string);
Sleep(300);
for (int i = 0; i < (strlen-1)*2-1; i++) {
scroll(string, strlen);
system("cls");
gotoxy(30, 12);
printf("%s",string);
Sleep(300);
}
for (int i = 0; i < 3; i++) {
system("cls");
gotoxy(30, 12);
printf(" ");
Sleep(300);
printf("%s", string);
Sleep(300);
}
}
void gotoxy(int x, int y)
{
COORD Pos = { x - 1,y - 1 };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
}
void scroll(char* string, int strlen)
{
char temp;
temp = string[0];
for (int i = 0; i < strlen-1; i++) {
string[i] = string[i + 1];
}
string[strlen - 1] = temp;
}