| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Someone compile this! i cant get it to!
this is the code that i need compiling, it says it needs headers but i cannot find them!
Code:
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
int main(int argc, char *argv[])
{
DIR *dip;
struct dirent *dit;
int i = 0;
/* check to see if user entered a directory name */
if (argc < 2)
{
printf("Usage: %s <directory>\n", argv[0]);
return 0;
}
/* DIR *opendir(const char *name);
*
* Open a directory stream to argv[1] and make sure
* it's a readable and valid (directory) */
if ((dip = opendir(argv[1])) == NULL)
{
perror("opendir");
return 0;
}
printf("Directory stream is now open\n");
/* struct dirent *readdir(DIR *dir);
*
* Read in the files from argv[1] and print */
while ((dit = readdir(dip)) != NULL)
{
i++;
printf("\n%s", dit->d_name);
}
printf("\n\nreaddir() found a total of %i files\n", i);
/* int closedir(DIR *dir);
*
* Close the stream to argv[1]. And check for errors. */
if (closedir(dip) == -1)
{
perror("closedir");
return 0;
}
printf("\nDirectory stream is now closed\n");
return 1;
}
cheers |
|
#2
|
|||
|
|||
|
What operating system and compiler are you using?
-KM- |
|
#3
|
|||
|
|||
|
Before I risk my system, whats the program do exactly, im unfamilar with some of those commands.
|
|
#4
|
|||
|
|||
|
im using XP with Microsoft VS 6.0 standard compiler
it just basically saves the titles from the contents of a fonder to a text file i think! i dont really know to be honest, a mate has asked me to compile it for him and it aint working! lol but i am fairly sure that is what its for! lol |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Someone compile this! i cant get it to! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|