No matter which language you want to learn, there are almost no exceptions starting with hello and world. Today I am no exception.
Write this articleArticleThe purpose is to use xcode or vs to writeCodeAlmost all are compiled, linked, and run using graphical tools. For a long time, I have no idea what these graphic tools have helped us, and I have no idea what to do after some system environment setup problems.
Mac is a graphical Operating System Based on the Unix kernel.So using terminal for programming is actually a programming in Unix. Here we only demonstrate one of the simplest methods.
1. First open the terminal application and run the CD command to the location where you want to create the file.
2. Then open the nano Editor, such as nano helloworld. C. Then open the nano editor and automatically name the file to be written as helloworld. C.
3. In the nano Editor, enter
# Include <stdio. h>
Int main ()
{
Printf ("jackysay Hello to you \ n ");
Return 0;
}
4. Press the shortcut key "Control + X" in the nano editor to exit the nano editor. The Nano will prompt you to save the file and enter "Y ".
5. Input GCC helloworld. C-o XXX in terminal to generate a xxx that can run.Program
6. Input./xxx to run the program. You can see that "Jacky say hello to you" is output on the terminal screen.
I have two questions)
1. As for # include <stdio. h>, this line of code contains this file, but I did not find the stdio. h file in my Mac. Why?
2. Even if the stdio. h file is found above, where is the implementation file of the function called printf in the following code? It is estimated that it should be a library file. Where is the library file? Or is there no library file, just like the Java Virtual Machine Concept, the user must ensure that the library file corresponding to stdio. H will be installed on the machine running the program? Thus, the compiled program contains library files and the size of the compiled program is omitted?