How do you make a double click c++ file?

Hello,

I've created the following program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*

Outputs the prime factorisation of a number.

*/

#include <iostream>
#include <cmath>

using namespace std;

int checkprime(int k);
int smallestprimedivisor(int d);

int main(){

int n;
char b='y';

while(b=='y'){

cout << "Which number would you like to decompose into primes?:";
cin >> n;

if(checkprime(n)){cout << n;}

while(!checkprime(n)){ 	cout << smallestprimedivisor(n) << 'x';
						n = n/smallestprimedivisor(n);}

cout << n << '\n';

cout << "Do you wish to continue?(y/n):";
cin >> b;

}

return 0;

}

int checkprime(int k){

//Checks if a number is prime.  Outputs 1 if it is, and 0 if it isn't.
				
				int i;
				if( k==2){ return 1;}
				if(!(k%2)){return 0;}

				for(i=3; i<=pow(k, 0.5); i+=2){if(!(k%i)){	return 0;}}
				return 1;

}

int smallestprimedivisor(int d){

//Finds the smallest prime that divides a number

				int h;
				if(checkprime(d)){ return d;}
				if(!(d%2)){ return 2; }
				
				for(int i=3; i<=d; i+=2){	if(checkprime(i)){ 	h = d%i;
																if(!h) {return i;}}}

}

				
												


...and it works well. I want to share it with a friend of mine, but they aren't into programming so don't know how to compile and run it themselves. I'd like to send them a .exe file that they can double click on, and open in command prompt so they can use it. I have no idea how to do this!

The problem is compounded further from the fact that i'm using linux. I need to be able to compile code into a .exe file in linux, which seems a little weird.

It must be a common thing to do, so how do you do it?
I haven't done it but there are online tools that will let you compile a C++ file, maybe some of them let you make a .exe and save to your hard drive.
I managed to get a .exe file that runs in linux through wine. I followed this quote here:

ne option of compiling for Windows in Linux is via mingw. I found a very helpful tutorial here.

To install mingw32 on Debian based systems, run the following command:
sudo apt-get install mingw32 mingw32-binutils mingw32-runtime

To compile your code, you can use something like:
i586-mingw32msvc-g++ -o myApp.exe myApp.cpp

You'll sometimes want to test the new Windows application directly in Linux. You can use wine for that, although you should always keep in mind that wine could have bugs. This means that you might not be sure that a bug is in wine, your program, or both, so only use wine for general testing.

To install wine, run:
sudo apt-get install wine


from:

http://stackoverflow.com/questions/2033997/howto-compile-for-windows-on-linux-with-gcc-g

I thought I was done! However, I just transferred it to my Dad's windows 7 pc to check, but it said the file was corrupted. I'll mess around with it more tomorrow, but is there anything obviously wrong?
Topic archived. No new replies allowed.