help me please - i/o files

hey everybody,
i really dont know, what i did wrong.. the code worked until i added the writeValues function
here's my code

# include <iostream>
#include <string>
#include <fstream>

using namespace std;

void replace (char[], char*, char*);
void writeValues (ofstream&, string, char[]);

int main()
{
string filename;
ofstream outputFile;
char source[80];
char origin, replacement;
cout << "Enter a string: " ;
cin.ignore();
cin.getline (source,20);
cout << "Enter character to replace: ";
cin >> origin;
cout << "Enter replacement character: ";
cin >> replacement;
replace(source, &origin, &replacement);
cout << "Enter name of output file: ";
getline(cin, filename);
writeValues (outputFile, filename, source);
cout << source << endl;
return 0;
}
void replace (char source[], char *origin, char *replacement)
{
int x=0;
do{
if (source[x] == *origin)
{
source[x] = *replacement;
}
x++;
}while (source[x] != '\n');

}

void writeFile(ofstream & output, string s, char source[])
{

output.open(s);

output << source << endl;

output.close();
}
Last edited on
What makes you think you did something wrong?
it's just not working :(
what do you mean "not working"? How is it not working? Do you get compiler errors? Does it run but crash? Does it run and not do what you expect?

We can't solve a problem when we don't know what the problem is.


EDIT:

Actually I see it now. You prototyped the function as writeValues, but below when you give it a body you named it writeFile.

But my point above stands. We shouldn't have to pull teeth to get the problem.
Last edited on
thanks for your help! it works! I'll try to be more specific and detailed next time :)
Topic archived. No new replies allowed.