Simple & Stupid C++ question

R

Ryan Waye

I have looked extensively, and I have been unable to find commands that
allow a C++ program to manipulate other files. How do I make C++ do
simple things like copy and past files, and navigate directories? Also,
where is a good command reference that I can use so I dont have to post
these annoying questions?

RW
 
P

Phlip

Ryan said:
I have looked extensively, and I have been unable to find commands that
allow a C++ program to manipulate other files. How do I make C++ do
simple things like copy and past files, and navigate directories? Also,
where is a good command reference that I can use so I dont have to post
these annoying questions?

Use http://groups.google.com to find the group that supports your compiler.

This newsgroup is only qualified to discuss raw C++, which can run on things
without file or folders.

Your platform will come with libraries that handle these details, but
anything you write will be relatively bound to your platform. Research
"POSIX".
 
A

Alf P. Steinbach

* Ryan Waye:
I have looked extensively, and I have been unable to find commands that
allow a C++ program to manipulate other files.

The standard C++ library has many type-safe classes that do that; have
you looked at e.g. std::eek:fstream?

The standard C library has many somewhat more unsafe functions and
structures. Have you looked at e.g. std::fprintf?

The C routines are generally way more efficient (but less safe) than the
C++ classes. And for even greater efficiency and less safety you can
use platform-specific functionality. Or de-facto portable, the old Unix
'read' and 'write' functions (they appear in different header files
depending on the compiler, and some compilers may not support them).

How do I make C++ do simple things like copy and past files

Assuming you mean copy and paste as in a GUI, that is not simple, and
it's platform-specific.

If you really need what you seem to be saying (probably not, but
anyway), then you need to use platform-specific functionality.

Consider that many platforms C++ is used on do not have GUI's.

and navigate directories?

The standard (C plus C++) library does not help you out there. However,
it's not quite in platform-dependent land. For example, take a look at
Also,
where is a good command reference that I can use so I dont have to post
these annoying questions?

Read the FAQ (go google).

Get yourself "The C++ Programming Language" plus "Accelerated C++".

Get yourself a copy of the C++ standard and/or the CD2.

Get yourself documentation for your specific platform(s) and
compiler(s).

And so on... ;-)
 
R

Ryan Waye

Phlip said:
Ryan Waye wrote:




Use http://groups.google.com to find the group that supports your compiler.

This newsgroup is only qualified to discuss raw C++, which can run on things
without file or folders.

Your platform will come with libraries that handle these details, but
anything you write will be relatively bound to your platform. Research
"POSIX".
I am sorry. I did not mean to get off topic, and thanks for pointing me
in the right direction.

RW
 
D

David Harmon

On Wed, 23 Jun 2004 00:40:36 -0400 in comp.lang.c++, Ryan Waye
I have looked extensively, and I have been unable to find commands that
allow a C++ program to manipulate other files. How do I make C++ do
simple things like copy and past files, and navigate directories?

Opening files, reading the contents into variables, and writing out new
files are all reasonably straightforward using standard stream classes.

This issue is covered in Marshall Cline's C++ FAQ. See section "[15]
Input/output via <iostream> and <cstdio>". It is always good to check
the FAQ before posting. You can get the FAQ at:
http://www.parashift.com/c++-faq-lite/
 
A

AngleWyrm

The C++ hat random selection container:
http://home.comcast.net/~anglewyrm/hat.html
Ryan Waye said:
I have looked extensively, and I have been unable to find commands that
allow a C++ program to manipulate other files. How do I make C++ do
simple things like copy and past files, and navigate directories? Also,
where is a good command reference that I can use so I dont have to post
these annoying questions?

#include <cstdlib> // system

int main() {
system("echo Hi.");
system("dir /b /w");
system("pause");
system("C:");
system("CD c:\\");
system("dir /p");
system("pause");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top