hello everybody
I had a question which i found an answear to on the
FAQ however C is my first programming language and i
dont really understand it all. Can somebody explain
a few things please.
This is the code i found;
Code:
/*
* This program displays the names of all files in the current directory.
*/
#include <dirent.h>
#include <stdio.h>
int main(void)
{
DIR *d; /*what does this mean?*/
struct dirent *dir;
d = opendir("."); /* and this*/
if (d)
{
while ((dir = readdir(d)) != NULL)
{
printf("%s\n", dir->d_name); /* and this (dir->d_name)*/
}
closedir(d);
}
return(0);
}
I guess i just wanna understand how the code works and how i can chage the directory
it looks into.