Tiff Tiff - 1 year ago 82
C Question

Write to a file in the current directory

I am required to run my compiled program using my account in university's HPCC center. My program should output the results in a text file, so I am using


FILE *fp = fopen("Users/Tiff/Documents/output.txt", "w+");

In my computer, I can simply specify the entire path but in HPCC I don't know my account's path on HPCC's main cluster. How do I make my program output the result in the same directory on my HPCC account without having to know the full path?

Answer Source

You should be able to use the following code:

FILE *fp = fopen("output.txt", "w+");

The file "output.txt" would be in the current directory.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download