I have been working through a C++ course and am making slow progress. I enrolled for a course and to my surprise found it to be Active C which is for apple Mac. Whilst doing the first lesson I found very few differences so will continue with the course.
I need to try and understand the programing in C++ is really interesting and I can see that I should be able to achieve my ultimate goal.
What I would like to understand is when you have written the program is there a way to run it in windows. what I am trying to say is lets assume I write a program that does graphs in C++ and I want to save it and give it to my friends to run it on their computers running windows. is this going to be possible and what is the process to do this.
I am a long way off from this but need to know what the procedure is to achieve the end result so that I can understand the process I am working towards
> I write a program that does graphs in C++ and I want to save it and give it to my friends
> to run it on their computers running windows.
> is this going to be possible and what is the process to do this.
Write the C++ program, compile and link it to produce an executable file (typically a file with a .exe extension on Windows). If you have used third party graphics libraries in your program, link to them statically. You can then give the executable file to someone, and they would be able to run it as it is on their Windows machines.
Thank you very much for the help. The Graphics are a long time off I fear I am still at the hello world and what is your name stage.
What do I need to use to do to produce an executable file.
I know there is no need to get a simple program to say hello world to run on anyone's computer but if possible it will help as I go along with the small projects eventually to achieve the ultimate goal.
So I think what I am asking is what do I need to do to change my c++ program to an executable file.
And is it possible to run small programs like this in Windows
Try this (make the program wait for a new line to be entered instead of quitting in a flash):
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <stdio.h>
int main()
{
printf("Hello world!\n");
// make the program wait for a new line to be entered
puts( "press ENTER to quit" ) ;
int c = 0 ;
while( c != '\n' && c != EOF ) c = getchar() ;
return(0);
}
That works perfectly thank you. Now the million dollar question. How do I convert it to a windows program save it on a flash drive and run it on another PC not in the cmd environment
Copy the executable - in the above example name.exe - to the flash drive. And then you can run it directly from the flash drive on other windows machines.