Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // vlad.ryad.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <cstdlib>
- #include <iostream>
- #include <stdio.h>
- #include <string>
- using namespace std;
- /*
- *
- */
- bool str_start(string str, char *sim, char *sl);
- int main() {
- setlocale(LC_ALL,"RUSSIAN");
- string line;
- char *buf = new char;
- char *sl = new char[1];
- cout << "Введите строчку:" << endl;
- getline(cin, line);
- cout << "Введите набор символов" << endl;
- cin >> buf;
- if (str_start(line, buf, sl)) {
- cout << "Строчка начинает с:" << buf << endl;
- }
- else {
- cout << "Строчка не начинается массивом символов" << endl;
- }
- system("pause");
- return 0;
- }
- bool str_start(string str, char *sim, char *sl) {
- bool flag = 0;
- int x = 0;
- while (str[x] != '\0') {
- if (str[x] != ' ') {
- for (int i = 0; i<sizeof(sim); i++) {
- if (str[x] != sim[i]) {
- break;
- flag = 0;
- }
- else {
- flag = 1;
- continue;
- }
- }
- }
- x++;
- }
- return flag;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement