Answers for "check if value in exist in a file c++"

C++
2

c++ check if file exits

#include <fstream>
#include<iostream>
using namespace std;
int main() {
   /* try to open file to read */
   ifstream ifile;
   ifile.open("b.txt");
   if(ifile) {
      cout<<"file exists";
   } else {
      cout<<"file doesn't exist";
   }
}
Posted by: Guest on January-28-2021
0

c++ how to check whether a file exists?

#include <filesystem>

void do_something()
{
 	if (std::filesystem::exists(FILE_PATH))
    {
     	std::cout << "yes, that file exists" << std::endl; 
    }
}
Posted by: Guest on February-03-2022

Code answers related to "check if value in exist in a file c++"

Browse Popular Code Answers by Language