Skip to content

Commit

Permalink
Added automatically file closing function
Browse files Browse the repository at this point in the history
  • Loading branch information
Shikyo Kira committed Aug 31, 2018
1 parent 20897fa commit ebf71c3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions readtextfile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef READTEXTFILE_H_
#define READTEXTFILE_H_

struct TextFile
{
FILE* file;

TextFile(std::string filename)
{
fopen_s(&file, filename.c_str(), "r");
}

FILE* GetFile()
{
return file;
}

~TextFile()
{
fclose(file);
}
};

#endif

0 comments on commit ebf71c3

Please sign in to comment.