#define and Streams
-
Hi everyone, especialy those nice gents who actualy answer the questions! ( Ladies? :laugh: ) I know that you can
#define fileName "myFile.txt"
a string in the globals area, and when you need to you canstream.open(fileName)
so you wont have to write the file name every time you open a stream. My question is this can the same logic be used to define the actual stream for example#define ifstream inFileStream
so that I wont have to declare the streams inside functions that need to use them. So that the only line relating to a stream in the function would beinFileStream.open(fileName)
. This should also remove the need to pass the streams to functions since I will be able to open and close them any where any time. Thanks in advance! -
Hi everyone, especialy those nice gents who actualy answer the questions! ( Ladies? :laugh: ) I know that you can
#define fileName "myFile.txt"
a string in the globals area, and when you need to you canstream.open(fileName)
so you wont have to write the file name every time you open a stream. My question is this can the same logic be used to define the actual stream for example#define ifstream inFileStream
so that I wont have to declare the streams inside functions that need to use them. So that the only line relating to a stream in the function would beinFileStream.open(fileName)
. This should also remove the need to pass the streams to functions since I will be able to open and close them any where any time. Thanks in advance!