Ok so I want to have the user imput a name of a file to decode it. How would I do that?
EX:
cin>>fill
ifstream in (fill)

Recommended Answers

All 7 Replies

Explain what you mean by decode

Oh someone can put a value in and the program would save it with a simple althogram. (*8776+8)
It has no connection to what I'm trying to do.

I think you mean algorithm

Save the value to a file?

No like the person can type the name of the file an it would use that. The contense of the files isn't really my problem. The program can open and decode the file or make a file and encrypt it. How could I use user imput as the filename.

Oh switched from string to char[] and it worked. Guess code::blocks strings arnt legit in this senario.

First of all you need to define file stream

#include <fstream>

Next you need to declare the file reference

ifstream infile ("filename.txt");//this is the name of the input file
ofstream outfile ("filename2.txt"); //this is the name of output file

then only you can read the data from input file and write to another file
//read

infile >>firstname >>lastname; //reading from input file
outfile >>"Name:" >>firstname >>lastname;//write to output file

it should works for VC++ or code::blocks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.