Convert a file's name into a string - C Program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • animeprogrammer
    New Member
    • Jan 2014
    • 13

    Convert a file's name into a string - C Program

    Hello there, can i ask if there is a way to convert a file's name into a string.

    Sample:

    filename = testcode.txt

    it will convert the file's name into a string:

    char convert[100];

    covert = name of file

    Is this possible?

    Thank you guys ;_;

    Regards,
    AnimeProgrammer
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I'm not sure what the question is considering that a file name is already a string.

    Code:
    const char filename[] = "testcode.txt";

    Comment

    • animeprogrammer
      New Member
      • Jan 2014
      • 13

      #3
      sorry, i guess i didn't made it create,

      Example is i have a file, a text file that is. It's file name is textfile.txt

      How can i convert that filename into a string.

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Do you mean how can you read the file names in a specific directory without knowing ahead of time what files are in the directory? If so we would need to know what platform you are using because the solution is platform specific.

        In any other case the file name would be supplied somehow, hard coded into the program, supplied on the command line, given as input by the user to the program. In all these cases the file name would, of necessity, have to already be a string.

        Comment

        Working...