thanks tuxdev. found this in searches based off your link:
Code:
/* print files in current directory in reverse order */
#include <dirent.h>
main(){
struct dirent **namelist;
int n;
n = scandir(".", &namelist, 0, alphasort);
if (n < 0)
perror("scandir");
else {
while(n--) {
printf("%s\n", namelist[n]->d_name);
free(namelist[n]);
}
free(namelist);
}
}
does almost exactly what i need so i think i can adapt
it if i can get this working. it produces errors when
i compile it. i get:
perror was not declared in this scope
printf was not declared in this scope
free was not declared in this scope
free was not declared in this scope
how do i properly declare these? or do i simply have
the wrong commands there for c++?
edit:
it was pointed out to me elsewhere that this is c code.
added:
#include <cstdio>
int main()
return 0
Code:
/* print files in current directory in reverse order */
#include <cstdio>
#include <dirent.h>
int main(){
struct dirent **namelist;
int n;
n = scandir(".", &namelist, 0, alphasort);
if (n < 0)
perror("scandir");
else {
while(n--) {
printf("%s\n", namelist[n]->d_name);
free(namelist[n]);
}
free(namelist);
}
return 0;
}
and am now left with only:
free was not declared in this scope
free was not declared in this scope
how do i declare 'free'? or is it a missing header?
thanks again,
BabaG
thanks,
BabaG