writing to a txt file

I'm trying to calculate the time taken for running selection sort v/s merge sort. The time taken is on standard output using cout. However, I want to put this into a file.

I have the following as part of my program:

1
2
3
4
5
6
 fstream read_file;
    
    read_file.open("sort.txt",ios::in);
//code for sorting goes here
double calc = (double) (ends - start) / CLOCKS_PER_SEC;
     read_file << "Running Time : " << calc << endl;


Although the sorting code worls fine, I don't see anything written into my sort.txt file. What am I missing here?
I got it, my sort.txt was in a different location from devc++
Works fine now.
Topic archived. No new replies allowed.