Does anyone know how to write a function which can have any stream handle passed to it?
For example.
const char Handle[]="outfile"
createfile(Handle,"Out.txt")
Printable View
Does anyone know how to write a function which can have any stream handle passed to it?
For example.
const char Handle[]="outfile"
createfile(Handle,"Out.txt")
What do you mean by "stream handle"? It looks like you're trying to pass a character array in that example.
If that's what you're asking then:
Hope this helps :)Code:
const char array[25] = {"outfile"} //needs decriptor brackets
const char file[25] = {"Out.txt"} //better not to pass strings
//so we will pass "Out.txt" as a variable as well
createfile(array, file);
//there you have 2 char strings being passed
//and your function definition would look like this
//with brackets in the definition to recieve the arrays
void createfile(char array[], char file[])
{
do stuff;
}