+ Reply to Thread
Results 1 to 2 of 2

Thread: How to get extension in C/C++ from the specified file name?

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    38

    How to get extension in C/C++ from the specified file name?

    I want to get the extension of the file from input file path.

    How to get it?

    I want similar like this:

    Code:
    void GetFileExtension(string filePath, string &extension)
    {
     //  assign extension 
    }
    Thanks.

  2. #2
    Code:
    void GetFileExtenstion(const std::string& strFileName, std::string& strExtension)
    {
    	char szExt[_MAX_EXT] = "" ;
    	_splitpath(strFileName.c_str(), NULL, NULL, NULL, szExt) ;
    	strExtension = szExt ;
    }
    Note:
    _splitpath is used to get the file extension.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts