#Include<fstream>
#include<>
#include<iostream>
#include<string>
using namespace std;
int main()
{

    string str="time is a great teacher, but unfortunatly"
"it kills all its  puplis. Berlioz";
ofstream outfile("ali.TXT");//ERROR
for(int j=0;j<str.size();j++)
outfile.put(str[j]);
cout<<"file written\n";
//system("pause");
return 0;
    }

please correct my code"ofstream outfile("ali.txt")"

#Include<fstream> // should be #include (all lowercase)
#include<>        // what's this meant to be?

You should also check whether your outfile is open.

if (!outfile.is_open() )
{
    // print an error message if you like
    return 1;
}

After writing to outfile, close it: outfile.close();
Instead of writing the entire string character by character you could use:
outfile << str;

Also search these forums for tutorials on code formatting. It's far easier for both you and others to find errors when your code is well formatted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.