C Tutorial
# C Programming Tutorial
!(#)
C is a general-purpose, procedural-oriented programming language. In 1972, Dennis Ritchie designed and developed the C language at Bell Telephone Laboratories for porting and developing the UNIX operating system.
C is a widely used computer language. It is as popular as the Java programming language, and both are widely used among modern software programmers.
The latest C standard is C18. Previous C standards include C17, C11... C99, etc.
**[Start Learning C Programming Now!](#)*## Who is this tutorial for?
This tutorial is specifically designed for software programmers who need to understand the C language from scratch. This tutorial will give you enough understanding of the C language to enhance your own professional expertise.
## What knowledge do you need before reading this tutorial?
Before you start studying this tutorial, you should have a basic understanding of computer programming terminology. Having a basic understanding of any programming language will help you understand C programming concepts and speed up your learning progress.
## Compile/Execute a C Program
## Example
#includeint main(){/* My first C program */printf("Hello, World! n"); return 0; }
[Run Example Β»](#)
**Example Explained:**
* Every C program must contain a **main()** function. Code execution starts from the **main()** function.
* **/* ... */** is used for comments.
* **printf()** is used for formatted output to the screen. The **printf()** function is declared in the **"stdio.h"** header file.
* **stdio.h** is a header file (standard input-output header file). **#include** is a preprocessor command used to include header files. When the compiler encounters the **printf()** function, if the **stdio.h** header file is not found, a compilation error will occur.
* The **return 0;** statement is used to terminate the program.
AI is thinking...
(#)[](#)
[Byte Ark Coding Plan supports mainstream large models like Doubao, GLM, DeepSeek, Kimi, MiniMax, etc. Officially supplied, stable and reliable. Configuration Guide Β₯9.9/month Activate Now](https://maas.xfyun.cn/modelSquare?ch=maas_lm_l2E)
## 4 Notes Write a Note
1. #0 Running Ant2018
138***86735@163.com [](#)2849 Running a **C** program, the main(int argc, char *argv[]) function receives arguments. **argc** is the number of arguments, **argv** is the string array. The index starts from **0**. The first element stores the filename of the executable program, and then the passed arguments are stored in order. For example, **HelloWorld.c**:
#include int main(int argc, char *argv[]){ /* My first C program */ printf("Executable program %s , number of arguments is [%d], output: [%s]n",argv,argc,argv); return 0;}
Compile **gcc HelloWorld.c** to get the executable **a.out**, then run the program:
./a.out Hello,World!Executable program ./a.out , number of arguments is , output: [Hello,World!](javascript:;)Running Ant2018
138***86735@163.com 8 years ago (2018-05-31)
2. #0 codeJun
460***593@qq.com [](#)1774 When it is int main(), the return value of **main()** is of type **int**, so it is return 0;. In current **C** standards, the return value of **main()** must be **int**, so it must be written as int main().
#include int main(){ /* My first C program */ printf("Hello, World!n"); return 0;}
When it is void main(), the return value of **main()** is void, so it can be omitted or be return;. However, this is an old style, and **void main()** is rarely used now, nor is it recommended. The purpose of mentioning it here is to remind everyone not to make such elementary mistakes.
#include void main(){ /* My first C program */ printf("Hello, World!n"); return ;}(javascript:;)codeJun
460***593@qq.com 8 years ago (2018-06-27)
3. #0 Bob
139***66638@139.com
(https://zhidao.baidu.com/question/456098400945650005.html) [](#)934 **warning: implicitly declaring library function 'printf' with type'int (const char *, ...)' **
The above warning generally occurs when using **printf** without including the header file **#include **
int main(){ printf("Hello, World!n"); return 0;}
The meaning of this warning is: **implicitly declaring library function printf with type "int (const char *,...)".**
**Background knowledge:** Because library functions like printf are so commonly used, when the compiler finds that the printf function is used directly in the source file without being declared, it will implicitly generate a declaration for printf. The compiler warning tells you that the implicit declaration it generated for printf is: int printf(const char *, ...)
**Consequence of the warning:** Usually, this warning is just a warning, not an error, and compilation can still proceed.
**Solution:** To remove this warning, just add the declaration of printf. The printf function is a library function, and its declaration is in the stdio.h file. Therefore, you just need to add **#include ** in the source file.
(#)Bob
139***66638@139.com
(https://zhidao.baidu.com/question/456098400945650005.html) 8 years ago (2018-08-10)
4. #0 Blue
185***00@qq.com [](#)1888 #include /* This line is a necessary format. stdio stands for system file library. You can also declare other headers. .h stands for header file, because these files are placed at the beginning of each program file. #include tells the preprocessor to insert the contents of the specified header file into the corresponding position of the preprocessor command. This preprocessor directive imports header files. indicates a system library. You can also use " " for a user-defined library. If you use " " and the specified library file is not found in your custom library, the system will automatically search the built-in libraries. If it's still not found, an error occurs. */int main() // The entry point of the program{ // The program starts running here/* int indicates a numeric format, returns a number. main() is the main function, indicating the program's entry point. A program can have one and only one main function. */ printf("hello C"); // Print "hello C"return 0; // Return the integer 0, because its type is int, it can only return an integer} // The program ends here(javascript:;)Blue
185***00@qq.com 7 years ago (201
YouTip