[Solved] Linux programming in C++ [closed]


The Unix API is C (as is the Windows API); any calls into Unix will look
like C. That doesn’t stop you from using C++, however: if the function
requires a char const*, for example, you can call
std::string::c_str() on an std::string.

Whether you want the Unix function (e.g read()) or the C++ (>> on a
stream) depends on what you need. The C++ functionality is generally at
a higher level; read() will only read an array of bytes, for example,
and will not parse integers in text format. On the other hand, you
have a lot more low level control with read() and its assorted
functions; if you need transactional itegrity, for example, you’ll need
to use open(), passing it the approriate flags, which aren’t available
in std::fstream::open(). More generally, the C++ functions that
involve interaction with the exterior (or with other threads) are built
on the underlying Unix system calls. They provide a higher level of
abstraction, and will generally be simpler to use, but in specific
cases, they may not offer all of the functionality available at the lower levels.

3

solved Linux programming in C++ [closed]