Цитата(pilismok @ 22.11.2007, 14:31 ) | | Я начинаю только программировать на СИ |
Цитата(FREEDEV @ 22.11.2007, 14:58 ) | #include <iostream> #include <string> #include <conio.h>
... std::cout<<"*"; |
Цитата(pilismok @ 22.11.2007, 15:07 ) | | но мне как-то не очень понятно)) я пишу на С++31 |
попробуй так:
| Код | #include <stdio.h> #include <conio.h> #include <string.h>
void DrawLine(); void DrawWindow(const char *str);
void main() { char str[50] = ""; int i = 0; char ch;
clrscr(); DrawWindow(str); gotoxy(2,2);
ch = getch();
while(i < 48 && ch != 13) // выходим из цикла, если вводим больше 48 символов, или если нажимаем enter { str[i++] = ch; DrawWindow(str); gotoxy(i+2, 2);
ch = getch(); }
if (i == 48) { gotoxy(1, 5); printf("Bolishe 50 simvolov vvesti nelizea"); getch(); } }
void DrawLine() { int i;
for(i = 0; i < 50; ++i) { printf("*"); }
puts(""); }
void DrawWindow(const char *str) { int i; int len = strlen(str);
clrscr();
DrawLine();
printf("*");
printf(str);
for(i = 0; i < 48 - len; ++i) { printf(" "); }
puts("*");
DrawLine(); }
|
|