joe.bloggs
joe.bloggs

Reputation: 1

Output files in C

I apologise if this is a trivial/stupid question but I'm new to programming and don't quite understand file outputs in C.

I've written some code and the bits to do with the output file are here:

FILE *output_path;
output_path=fopen("myfile.out", "w");
  .
  .
  .
fprintf(output_path, "%lf\n", x);

What I would like to do is view my output but I don't know how to open this file or even locate where it is on my computer. How do I do this?

Upvotes: 0

Views: 112

Answers (2)

xxx
xxx

Reputation: 189

Since the OP is running the program on PuTTY, the cat command should do the trick.
After execution of the program, run cat myfile.out to see the contents of the file myfile.out

Upvotes: 0

D3Hunter
D3Hunter

Reputation: 1349

myfile.out will be created in your working directory. Normally its the directory where you get you program executed unless you have changed it with chdir

Upvotes: 2

Related Questions