Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  123
Language: C/C++
Code:
#include 

#ifdef _WIN32

/* Compiling for Windows */

#include 

int main(void)
{
WIN32_FIND_DATA f;
HANDLE h = FindFirstFile("./*", &f);
if(h != INVALID_HANDLE_VALUE)
{
do
{
puts(f.cFileName);
} while(FindNextFile(h, &f));
}
else
{
fprintf(stderr, "Error opening directoryn");
}
return 0;
}

#else
#ifdef __unix__

/* Compiling for UNIX / POSIX */

#include 
#include 

int main(void)
{
DIR *dir = opendir(".");
if(dir)
{
struct dirent *ent;
while((ent = readdir(dir)) != NULL)
{
puts(ent->d_name);
}
}
else
{
fprintf(stderr, "Error opening directoryn");
}
return 0;
}

#else
#ifdef __TURBOC__

/* Compiling for MS-DOS */

#include 

int main(void)
{
struct ffblk ffblk;
if(findfirst("*.*", &ffblk, 0) == 0)
{
do
{
puts(ffblk.ff_name);
} while(findnext(&ffblk) == 0);
}
else
{
fprintf(stderr, "Error opening directoryn");
}
return 0;
}

#else
#error Unsupported Implementation
#endif
#endif
#endif
          
Comments: