Tiff Tiff - 1 month ago 4x
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?


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.