Help with Strings

I'm having difficulty working with C++'s strings. I'm writing a program to solve a set of linear equations. I'd like to save the solution for various values of N (the size of the system is N X N), and n, a parameter within the system, to a text file, for later analysis. Ideally, I'd like to create a program that lets me enter a value for N (eg. 50 or 4000) and n (eg. -3 or -5) and then saves the solution to the system to a file called "50N_-3n.dat" or something.

1. How do I enter an int, and then make it a string? the following, stolen from the internet, does not do it:
string int_to_s(int num, string& converter){
toString << num;
converter = toString.str();
return converter;
}

This returns: myfirst.cpp: In function ‘int main()’:
myfirst.cpp:12: error: a function-definition is not allowed here before ‘{’ token

I've placed this function definition well below int main() {

2. Once I create a string with value "50", how do I glue it into an output file name?

In this test code, en is supposed to be "50", and the file should be myhouse_50.dat. C++ says:
myfirst.cpp:28: error: expected `;' before ‘en’
myfirst.cpp:29: error: aggregate ‘std::ofstream outfile’ has incomplete type and cannot be defined

How do you get outfile.open to understand the VALUE of name?
As you can probably tell, I have very little experience with C++. Thanks,

1. How do I enter an int, and then make it a string? the following, stolen from the internet, does not do it:
string int_to_s(int num, string& converter){
toString << num;
converter = toString.str();
return converter;
}

There are multiple ways to convert from an int to a string. One was is to use itoa() function to do so but it will store it in a char array first, which is easily fixed. However, it doesn't calculate for buffer overflow, so it can crash the system.

Another sort of unconventional way is to use stringstream to do it. It takes the number and throws it into a buffer, which you can then tell it to store in a string. I've been told that this way isn't that great, don't remember why, but it does work.

2. Once I create a string with value "50", how do I glue it into an output file name?

Below is how I did it. When using outfile.open(name) where name is a string, you need the name.c_str() or it will not like it (sorry, I can't remember exact reason, it's been a while since I've used that). And when trying to set name equal to other strings, us + to show that they are added together to form the string that will be declared as name. Everything is below.