Funktion in CPP setzen

char str[20] = "I love Grepper.";
int l = strlen(str);

ofstream file ("myfile.txt");

for(int i=0; i<l; i++)
{
  file.put(str[i]);
}
cout<< "process completed\n";

file.close();
Sleep deprived