Stream errors
Hello.
I made this program, but I don't know what is wrong:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <fstream>
#include <string>
#include <sstream>
using std::stringstream;
using std::string;
using std::ifstream;
using std::ofstream;
int main(int argc, char* argv[])
{
char* str;
string name_t;
name_t = argv[1];
ifstream file;
file.open(name_t.c_str());
ofstream ofile;
string name;
stringstream name_ss;
name_ss << "code_" << name_t.c_str();
name = name_ss.str();
ofile.open(name.c_str());
ofile<<"<code>";
while(!file.eof())
{
file >> str;
if(str == "\n")
{
ofile << "<br>";
}
if(str == "<")
{
ofile << "<";
}
if(str == ">")
{
ofile << ">";
}
else
{
ofile << str;
}
}
ofile<<"</code>";
}
|
Any help will make me happier :)
Thanks.
Last edited on
Topic archived. No new replies allowed.