{
}
Online Python Compiler
Online R Compiler
Online SQL Editor
Online HTML/CSS Editor
Online Java Compiler
Online C Compiler
Online C++ Compiler
Online C# Compiler
Online JavaScript Compiler
Online Typescript Compiler
Online GoLang Compiler
Online Rust Compiler
Scala Online Compiler
Dart Online Compiler
Ruby Online Compiler
Online PHP Compiler
Online Swift Compiler
Generating Link
Generating Link
Share your code
Share code
Copy Link
Copied to clipboard
or share using
CYBER
CYBER
CYBER
CYBER
CYBER
66
%
OFF
Week
Week
Week
Week
Week
Stop copy pasting code you don't actually understand
Build the coding confidence you need to become a developer companies will fight for
Stop copy pasting code you don't actually understand
Become a PRO
Become a PRO
CYBER
CYBER
CYBER
CYBER
CYBER
66
%
OFF
Week
Week
Week
Week
Week
Stop copy pasting code you don't actually understand
Build the coding confidence you need to become a developer companies will fight for
Stop copy pasting code you don't actually understand
Become a PRO
Become a PRO
C++ Online Compiler
Learn Python App
Learn Python
main.cpp
Output
main.cpp
Share
Run
Run
#include <iostream> #include <filesystem> #include <fstream> #include <string> namespace fs = std::filesystem; // Funkcja sprawdzająca, czy plik zawiera dany ciąg znaków bool containsString(const fs::path& filePath, const std::string& searchString) { std::ifstream file(filePath); if (!file) return false; // Nie udało się otworzyć pliku std::string line; while (std::getline(file, line)) { if (line.find(searchString) != std::string::npos) { return true; } } return false; } // Funkcja przeszukująca foldery i podfoldery void searchFiles(const fs::path& directory, const std::string& searchString) { try { for (const auto& entry : fs::recursive_directory_iterator(directory)) { if (entry.is_regular_file()) { // Sprawdzamy tylko pliki if (containsString(entry.path(), searchString)) { std::cout << "Znaleziono w pliku: " << entry.path() << '\n'; } } } } catch (const std::exception& e) { std::cerr << "Błąd: " << e.what() << '\n'; } } int main() { std::string folderPath, searchString; std::cout << "Podaj ścieżkę do folderu: "; std::getline(std::cin, folderPath); std::cout << "Podaj szukany ciąg znaków: "; std::getline(std::cin, searchString); if (!fs::exists(folderPath) || !fs::is_directory(folderPath)) { std::cerr << "Podana ścieżka nie istnieje lub nie jest folderem." << std::endl; return 1; } searchFiles(folderPath, searchString); return 0; }
Output
Clear