Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // nikita166.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include "iostream"
- #include <conio.h>
- #include <Windows.h>
- void getCharMass(char *name, int size) {
- int counter = 0;
- int tempCharCode;
- while (counter < size)
- {
- tempCharCode = _getch();
- if (tempCharCode == 13) {
- std::cout << std::endl;
- name[counter] = '\0'; //Знак окончания строки
- break;
- }
- name[counter] = (char)tempCharCode;
- std::cout << name[counter];
- counter++;
- }
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- SetConsoleCP(1251);// установка кодовой страницы win-cp 1251 в поток ввода
- SetConsoleOutputCP(1251); // установка кодовой страницы win-cp 1251 в поток вывода
- char name[30];
- char otchestvo[30];
- char *initialText[] = { "Как Вас зовут?", "Введите свое имя, затем нажмите <Enter>",
- "Введите свое отчество, затем нажмите <Enter>", " -> " };
- std::cout << initialText[0] << std::endl
- << initialText[1] << std::endl << initialText[3];
- getCharMass(name, 30);
- std::cout << std::endl << initialText[2] << std::endl << initialText[3];
- getCharMass(otchestvo, 30);
- std::cout << "Здравствуйте, " << name << " " << otchestvo << std::endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement