Getting in a file whatever I type

I want a way by which I can easily obtain a list of all the inputs provided by me in a program in a text file. For example, suppose I have these functions

1
2
void manip(char*,const char*,int);  //a function to manipulate a string
bool Continue();  //a function which asks user to enter 'y'(yes) or 'n'(no) 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int main()
{
	char a[500],b[30];
	int n;
	cout<<"Enter main string ";
	cin>>a;
	do
	{
		cout<<"Enter auxillary string ";
		cin>>b;
		cout<<"Enter a number ";
		cin>>n;
		manip(a,b,n);
		cout<<"Result: "<<a<<endl;
	}
	while(Continue());
	return 0;
}

Suppose I enter "abc", "def", 3, 'y' ,"pqr", 4 & 'n' for the cin's.

I want a way to obtain this text file:
abc
def
3
y
pqr
4
n


The way to do it should not be writing "file<<" after every cin.

It should be like calling a function at the end of my program which will retrieve all input given during the program and write that to a file.
Or it can be a function that I call at the beginning of my program which will start syncing a file to whatever I type.

Edit: This would be a good way to keep track of what input I provide in a program. If I copy all the stuff in the file and paste it when I run a program again, I'll be able to replicate the program output and save time if the program asks for a lot of input.

Edit: This question was earlier in the Windows forum, but I shifted it here as I was getting no reply there and I'm not sure in which forum this question really belongs to. If you think this was a bad idea, please tell me.
Last edited on
Topic archived. No new replies allowed.