Skip to content

Instantly share code, notes, and snippets.

@bytepicker
Created December 1, 2015 10:37
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 bytepicker/f2efd631bf57049f12e7 to your computer and use it in GitHub Desktop.
Save bytepicker/f2efd631bf57049f12e7 to your computer and use it in GitHub Desktop.
small type analog
#include <iostream>
#include <fstream>
#include <string.h> // strcat
using namespace std;
int main(){
char name[100];
char ch;
for(;;){
cout<<"enter filename: "; cin >> name;
strcat(name, ".txt");
ifstream infile(name);
if(infile){
cout << "file opened!\n";
cout << infile.rdbuf();
cout << endl; }
else{
cout << "error opening file!\n"; }
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment