Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 2, 2022 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/410c87169f00168f37fe22fbdc9d18a3 to your computer and use it in GitHub Desktop.
Save parzibyte/410c87169f00168f37fe22fbdc9d18a3 to your computer and use it in GitHub Desktop.
// https://parzibyte.me/blog
#include <iostream>
#include <fstream>
using namespace std;
bool archivo_existe(string nombre)
{
ifstream archivo(nombre.c_str());
return archivo.good();
}
int main(int argc, char const *argv[])
{
string ubicacion = "existe.cpp";
if (archivo_existe(ubicacion))
{
cout << "El archivo existe\n";
}
else
{
cout << "El archivo NO existe\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment