Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Название темы: Задачка не получается
Показать сообщение отдельно

Аватара для bool

Старожил


Сообщения: 229
Благодарности: 9

Профиль | Отправить PM | Цитировать


что то вроде:
Код: Выделить весь код

#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <cstring>
using namespace std;

int main()
{
	
	ofstream out("test", ios::binary);
	char str[] = "bla bla bla bla . ble ble ble ble ble. blu blu blu blu. blo blo blo.";
	out.write(str,strlen(str));
	out.close();
	ifstream in("test", ios::binary);
	if(!in) {
		cout << "File didn't open\n";
		return 1;
	}
	char ch;
	string word;
	cout << "Input word: ";
	cin >> word;
	string s;
	while(!in.eof()) {
		in.get(ch);
		if(ch=='.') {
			if(s.find(word)!=-1) cout << s << endl;
			else cout << "No 8(\n";
			s.erase(0);
		}
		s=s+ch;
	}
	in.close();
	return 0;
}

Отправлено: 21:58, 19-08-2007 | #3

Название темы: Задачка не получается