Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

io.h, reading contents of a directory, ubuntu 14.04

28 views
Skip to first unread message

ag...@drrob1.com

unread,
Nov 16, 2015, 8:00:27 AM11/16/15
to
Hi. I am learning C++ after many years of using modula-2 on windows.

I now am working my way thru C++ all in one for dummies, by John Paul
Mueller and Jeff Cogswell.

On the chapter about getting the contents of a directory, they
describe io.h and _findfirst(), _findnext(), and struct _finddata_t.

This is not working under ubuntu 14.04. I located a version of io.h
in the /usr/src/linux-headers tree, copied it to my working directory,
but I'm still getting a lot of undeclared symbol errors.

How do I read the contents of a directory in Ubuntu 14.04?

Thanks,
Rob

Alf P. Steinbach

unread,
Nov 16, 2015, 8:17:23 AM11/16/15
to
Sounds like an ungood book, because those `_xxx` identifiers are
internal to the implementation, i.e. they're compiler and platform specific.

For portable code, use the Boost file system library.

It will probably be part of C++17.


Cheers & hth.,

- Alf


Scott Lurndal

unread,
Nov 16, 2015, 9:44:14 AM11/16/15
to
man readdir

jacobnavia

unread,
Nov 16, 2015, 10:47:55 AM11/16/15
to
Le 16/11/2015 13:59, ag...@drrob1.com a écrit :
> This is not working under ubuntu 14.04.


It can't work because _findfirst, etc are WINDOWS functions specific to
the microsoft compiler. The book assumes bloithely that you are under
windows and gives examples that are valid only for windows.

Under Ubuntu the thing is a bit more involved. Just look about
"readdir" and you will find more examples of reading a directory under unix

Nobody

unread,
Nov 18, 2015, 7:27:50 PM11/18/15
to
On Mon, 16 Nov 2015 14:44:03 +0000, Scott Lurndal wrote:

>>How do I read the contents of a directory in Ubuntu 14.04?
>
> man readdir

man 3 readdir

Otherwise you might get the section 2 page. Which, to be fair, starts off
with:

DESCRIPTION
This is not the function you are interested in. Look at readdir(3) for
the POSIX conforming C library interface.

0 new messages