what does this mean "\\*" in a string??

on msdn they have a "print all files in the directory" example and they say that they "prepare" the string for use with FindFirstFile().


I haven't seen this before but what does it mean?

"\\*"

Why do you have to append it to the directory name?

1
2
3
4
5
// Prepare string for use with FindFile functions.  First, copy the
   // string to a buffer, then append '\*' to the directory name.

   StringCchCopy(szDir, MAX_PATH, argv[1]);
   StringCchCat(szDir, MAX_PATH, TEXT("\\*"));


https://docs.microsoft.com/en-us/.../listing-the-files-in-a-directory

Edited by C_Worm on Reason: Initial post
\\ is because you want to put \ in string. You need to escape it when putting in C string. So "\\" becomes \ in memory.
* is called wildcard - it matches any string. If you use a*b then this matches axxxb, ayzzb, ... - basically anything that starts with a and ends with b. If you use *xx* then this matches anything that has xx in the middle of string - aaxxbb, xxxcc, zzzxx, ...

What their code does is create string in form "c:\path\*" - which means any file "*" under specified folder "c:\path".

Edited by Mārtiņš Možeiko on
The double backslash is to escape an single backslash in a string. In this case it's just to have the backslash separator between the directory name and the file name.

The star * is a wildcard character, a character used to signify that 0 or more character should be present in place of the star character.

The FindFirstFile function searches for the filename you specify. If you specify a directory name without \*, it will return the information about the directory. Since you want all the file in the directory, you use the wildcard to say that the file name is the directory name followed by a \ followed by 0 or more character.

You can be more precise: if you want to retrieve only .txt files, you can use "\\*.txt". If you want file starting with "lib" and finishing with "debug" with any extension you could specify "\\lib*debug.*". Note that I didn't verify those but I expect them to work.
Allright! thanks for clearing that out for me! :)