954,487 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to get files and store them...

hello there...uhmmm, im having problems with getting the file and storing them...like for example, you ask the user to input a file then that file will be stored...how do you get that file, and where do you store them?? thanks

jaepi
Practically a Master Poster
647 posts since Jul 2006
Reputation Points: 32
Solved Threads: 4
 

I think you may have misunderstood the assignment. Are you supposed to ask for the information to be put into the file? The name of the file? or both?

Is this a C or C++ program? What compiler and operating system?

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

uhmmm ask for the file name then store the file itself...like for example

.....................................................
enter file name of file you would like to store: dragon.jpg
........................................................
dragon.jpg then will be stored
, but idk how to get the file and store it..

yes, it is c++ in linux...help pls...

jaepi
Practically a Master Poster
647 posts since Jul 2006
Reputation Points: 32
Solved Threads: 4
 

>>but idk how to get the file and store it

don't know -- you will probably have to ask your teacher. Saving the file is easy but depends on whether you are writing a C or C++ program, which you failed to answer. I can only presume your program already has the data for the find in memory, or its in another file somewhere. But you need to get clarification from the instructions (please post them) or from your teacher.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
>>but idk how to get the file and store it but depends on whether you are writing a C or C++ program, which you failed to answer.



He did answer, he said he's using C++ and using the Linux Operating System.

jaepi, we don't have much information on specifically what your wanting to do and how to get this file.
Are you wanting to type in the file location and copy it to the current directory?.
Are you wanting to copy the file's contents, and write them to a file?

If you are going for the first option.
you can simply run a copy command using system() function to call the linux 'copy' command.

The second option you're looking to use "fstream"
which can be used by including. #include
in your file.

You need to identify exactly HOW your wanting to get the file,
and HOW your going to store it.

If you have the methods we can give you the code for these methods.


Drag...

dr4g
Junior Poster
136 posts since Apr 2007
Reputation Points: 35
Solved Threads: 5
 

>which can be used by including. #include
Please don't encourage the use of pre-standard headers. We're getting to the point where compilers will refuse to build code that uses them.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Theres absolutley nothing wrong with using the fstream library for handling Input/Output streaming.

dr4g
Junior Poster
136 posts since Apr 2007
Reputation Points: 35
Solved Threads: 5
 
Theres absolutley nothing wrong with using the fstream library for handling Input/Output streaming.

Are you talking about fstream or fstream.h?

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

using .h is bad

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

>Theres absolutley nothing wrong with using the fstream library for
>handling Input/Output streaming.
No, there's not. However, when you say to use fstream.h instead of fstream, you're not using the fstream library. You're using some non-standard library with inconsistent semantics that happens to be called fstream.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Yes, you should never use fstream.h

for more about File I/O see below
http://www.cprogramming.com/tutorial/lesson10.html

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

naure i love your animated avatar

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

How do you get an animated avatar?

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

be a sponsor

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

>be a sponsor
Or a moderator. One costs you money, the other costs you sanity.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

I think I can live without it then. :D I'm trying to ween myself off the pc.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

Are you back at work narue?

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

Okay, well i'm referring to the fstream library. not the .h file, i was unaware there was a difference.

dr4g
Junior Poster
136 posts since Apr 2007
Reputation Points: 35
Solved Threads: 5
 

>i was unaware there was a difference.
Now you are. To use the fstream library, you include , not .

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Yes that's pretty obvious.

dr4g
Junior Poster
136 posts since Apr 2007
Reputation Points: 35
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You