0

I would like to get a name of file from input and then read it. (Suppose that the file is in the directory of program.) To do that I need an absolute path. Please let me know how to achieve this goal using C. This a part of my code:

scanf("%s",&filepath1);
FILE * fdw = fopen(filepath1, "a");
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 3
    Remove the `&`. You must not have it there, regardless of whether `filepath1` is a pointer or an array. – paddy Mar 07 '17 at 00:49
  • http://stackoverflow.com/questions/229012/getting-absolute-path-of-a-file – Sean F Mar 07 '17 at 01:05
  • What are you asking for? If the user types an absolute path as the file name, then that's fine. If the user types a relative name, you'll be able to use that too. Do you want to convert a possibly relative name into an absolute path? Which platform are you working on? – Jonathan Leffler Mar 07 '17 at 02:54

1 Answers1

1

delete the '&' symbol.

char filepath1[SIZE] = {0};

scanf("%s", filepath1);

FILE * fdw = fopen(filepath1, "a");
yayaya
  • 135
  • 10