Code:
#include //<iostream>
#include <fstream.h>
#include <string>
#define arraySize(x) sizeof(x)/sizeof(x[0])
void Stream(char &file, char &ext, ofstream &create)
{
cout << "Type in a filename: ";
cin >> file;
cout << "\nType the file extension(ie: txt): ";
cin >> ext;
char *filename = new char[arraySize(file) + arraySize(ext)];
strcat(filename, file);
strcat(filename, '.');
strcat(filename, ext);
create.open(filename);
create.close();
}
int main(int argc, char *argv[])
{
char boob, lama;
ofstream x;
Stream(boob, lama, x);
cout << "\nFile created was: " << boob << "." << lama << endl;
cin.get();
return 0;
}
I'm pretty sure filename can't be constant... as it's created dynamically. Also, you were adding "." to a char, not only can't you use the + operator on chars, it would be '.' and not "."
Ah well, hope this helps.
Edit:: I'm pretty sure iostream.h is included in fstream.h, so you don't need to include the iostream header.