-
Using Buffer
How can I obtain list of current working directory--put them into a buffer, say size 1024 bytes, and then print them out on a temp file one per line?
This is my attempt:
#include <stdio.h>
char buffer[ 1024 ];
if (( "ls - l", buffer, 1024 ) < 0 )
printf( "ls: %s\n", buffer );
-
The current working directory is the directory you are currently in. Do you mean opbtain a list of the files in the direcotry you are on? If so this is OS dependent. If you are in linux:
man readdir
man opendir
man closedir
If you are in windows go to http://msdn.microsoft.com/ and look for GetFirstFile (I think) and GetNextFile.