0

I have a program in c. Input of this program is the address of a file. This program gets the complete address of input file like d:\bin\files\examples\data\file.txt. How can I correct the program that gets input in form of data\file.txt ? and the d:\bin\files\examples\ add itself.

2 Answers2

0

Just do it. while the c program is below the directory d:/bin/files/examples and compile ,then execute it with the direct argument data/file.txt.

xuefu
  • 61
  • 7
0

Take a look at getcwd function. You will get current working directory path. Apply your logic what part to add. Use sprintf to complete the path.

gangadhars
  • 2,584
  • 7
  • 41
  • 68