dirent.h

Hey, this isn't exactly an end of the world problem more a comfort issue. I've been using dirent.h recently and its been written for C as oppose for C++. So for outputting statements I'm having to use printf() etc and for someone who never initially learned C i much prefer the std::cout syntax. My question is, can I overload the insertion operators to use std::cout << instead of printf()?
Anywhere you can use printf you can use << .
What exactly are you printing?
Yeah that's what I thought, but when I tried to ouput a CString member of an object of type DIR I was getting an error not being able to do something or other. On second attmept it works fine though. Must have not been concentrating or something!
Ok scrap what I just said, I've got it again. This is pretty much what i'm doing:

1
2
3
DIR *ptrDir = NULL;
ptrDir = opendir(".");
std::cout << ptrDir->current << "> ";


Error:
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'dirent' (or there is no acceptable conversion)
That because the current member of the DIR struct is a structure itself.
You need the d_name member of the current structure.

Look at the dirent.h file
Thanks, I overlooked that structure and was just focusing on the DIR and dirent structures.
Topic archived. No new replies allowed.