Can I write to a file without ofstream?

I'm trying to write a quick function that asks the user for their name, and how many sales they made during a sales period. I know you can write in a file with ofstream and an object, but I was wondering if you could write directly to that file using cin, or something.

I've tried storing a name, and a double type, passing them into parallel arrays (which inhave to use for this assignment) and storing them in arguments that can be read by another function. It didn't seem to work properly, and I'm wondering if there's a simpler way to do that. I can provide my code if need be.

std::cin is an input stream, so no. You can write to a file using std::cout if the standard output has been redirected to a file, for example by start the program with program > file.txt.

I'm not sure what you mean in your second paragraph.
Topic archived. No new replies allowed.