Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <Windows.h>
- using namespace std;
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- ifstream fin;
- fin.open("file.txt");
- if (!fin.is_open()) {
- cout << "Ошибка открытия файла" << endl;
- }
- else {
- char word[40], longest_word[40];
- int size = 0;
- while (!fin.eof()) {
- fin >> word;
- if (strlen(word) > size) {
- strcpy(longest_word, word);
- size = strlen(word);
- }
- }
- fin.close();
- cout << longest_word << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement