Triple X - Your first program!

We start Triple X off by writing the most minimal program.

Why do we start with int main()?

How does the compiler treat white space?

Post in your own words below! :grin: Create new topics relating to this lecture in: #3_tx_uc2

int main () is a function that will be executed when program starts. Everything between the { } contains the statements that run the program. int is an integer data type hence the statement return 0; The compiler treats white space as nothing so the blank spaces will not expand with in the running program. Need to use ("\n"); to add new line or spaces in program

1 Like

We start with “int main()” because it is the function that c++ scripts run first when compiled and executed.

This means you have to have it and you must put your code in here or call you own functions from here to have your code run.

The c++ compiler ignores white space and we include it purely to make reading our code easier. There is an exception to this and that is anything contained in a string (between " " marks) will render the white space.

We start with the function "int main() " Because this is the function that will run the operating system. The compiler uses the white spaces to separate ideas and make the code more readable. I try to put the code in a single line, the first time I did without white spaces, what happened is that the program did not even compile, then I did the same but using the white spaces, this time the program compile and could run.

The difference I saw in putting everything on a single line is that it is understood less, instead if we put the code in different lines it is understood that what is inside the keys is what performs the function main(), therefore I think it is better to put everything in different lines to make the code more understandable.

We start with int main() because it is what our operating system looks for when it runs a C++ based program.

It completely ignores it, except for singular spaces that separate characters.

We start with int main because C++ runs main first a run time.
The reason int main is int and not void is because main returns a variable. We return 0.
The compiler ignores white space.

We started with main() because EVERY C++ program executable requires a main() to be able to be built.

The compiler ignores white spaces and this is completely for readability.

We start with int main() because it is required to start the program.
When the program is executed it looks for int main() first, I acts as the entry point and houses the code that will be executed in the program. For any other functions to execute, it must be called inside the main function. The compiler ignores white space.

it seems that because instructors did not tell me to close the project from previous videos i am writing codes for the project unwittingly by openning VS code in the lessons that follow.

We start with int main() because that is the gateway to all other code you will write. If you don’t include int main(), you can write all the code you want, but it is not going to understand it.

The compiler ignores white space–it’s only there to make it easier for humans to read, not computers.

we start with int main because it is the core code by which our program is built and run on

white space is totally ignored by the compiler ,for reading purposes

At around the 1:00 mark of the video @GavinMilroy says to immediately save the VS code file as “TripleX.cpp”. When I tried to do this I get an error code Unable to write file (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/TripleX.cpp').

I’m on a MacBook Pro running Mojave 10.14.6 if that matters at all.

How do I allow the permission?

Just incase anyone else has this issue, when I tried to save directly to my hard drive I got the error message in my original post. I switched the save location to my cloud and it worked.

If anyone has an idea of why I wouldn’t be able to save that file hit me up with a reply.

We start with int main() because the operating system running c++ looks for this function first to run the program. the int sets an integer (whole number value). The main is the name of the function. The () is used to pass arguments into the function which we have not done.

The function body {return 0;} sets the return value as 0 so that the operating system knows that if 0 is returned the program has run correctly. If any other value is returned is indicates an error.

The function int main() as we have it runs, then exits immediately.

The compiler completely ignores extra white space but keep the code concise and with easy readability.

int main() simple seems to be the function that gets it all going. the George Jetson of the Operation. and like C#, it seems to ignore white space, other than indenting to help organize code.

Question: You guys said I could follow with VS Community, and I was having trouble setting up VS code because I was always getting a directory error. Is there a ways to post lecture notes in the resources regarding the approach to codes with VS community as opposed to VS code, for those of use trying to follow allong? or else is there a way to display the terminal in VS community?

When I try to compile I get the following error.

‘cl’ is not recognized as an internal or external command,
operable program or batch file.

First lesson in and I’m stuck!

same here. Found the solution in video 9 at 7:40.

I believe they forgot how to show the installation of g ++ and cl…

I am researching here to try to adjust this. The visual studio 2019 oriented in the first classes is different from the one shown in this first example.

My suggestion to instructors is to put a lesson on where to look for, install and configure the g ++ and cl compilers, and explain if there is any difference between them.

29 days it was published and there was no answer, it makes me a little worried

EDIT: RESOLVED with cl in Visual Studio Community xD… see, sorry my interface in portuguese…

check out for a way to set up your c++ compiler in vs code

I just ran into this issue and found a solution. I’m also working on a Mac, the first thing is to move VS CODe from your download folder, to the applications folder. After that you just need to create a folder, or save somewhere else that is not your HDD.