Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use vi to create new CentOS mytest files to learn c language programming

Shulou Source: shulou.com Published: 2022-06-01 07:15:28 09月23日 Update

How to use vi new CentOS mytest file to learn c language programming, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail, people with this need can come to learn, I hope you can get something.

The characteristics of CentOS mytest system can be used not only as CentOS mytest learning for computer majors in colleges and universities, but also for CentOS mytest system open source enthusiasts and XX system users.

First create a new CentOS mytestc.c file using vi.

And enter the relevant c program code as follows: [OK_008@CentOS4 ~] $vi CentOS mytestc.c#include "stdio.h" in main () {printf ("Hello,this is my first program.");} "CentOS mytestc.c" [New] 5L, 77C written starts compilation. Gcc is mainly used for compiling the Calgary Cobb + program. Only the simple parameters-o and-g of gcc are used here. O indicates the name of the set output file.

G means to add mode information and prepare [OK_008@CentOS4 ~] $gcc-o CentOS mytestc-g CentOS mytestc.cCentOS mytestc.c:2: error: syntax error before "main" compilation error for gdb, prompting the syntax error before "main", and then use vi to modify it here. It is found that the data type int before main () is written as in. Oh, it's too careless. [OK_008@CentOS4 ~] $vi CentOS mytestc.c#include "stdio.h" int main () {printf ("Hello,this is my first program.");}

"CentOS mytestc.c" 5L, 78C written [OK _ 008@CentOS4] $gcc-o CentOS mytestc-g CentOS mytestc.c [OK_008@CentOS4 ~] $ls-there is no hint, indicating that the test passed, using ls, we find that there is an extra compiled CentOS mytestc file now.

Debugtest Desktop CentOS mytestc.c mytxt.txt TestFiledebugtest.c CentOS mytestc mytxt1.txt OK008Filed untar [OK _ 008@CentOS4 ~] $. / CentOS mytestc-- this command executes the CentOS mytestc file you just generated. Hello,this is my first program. [OK _ 008@CentOS4] $- here is the execution result. Ok succeeded. In order to look good, I modified the program and added an enter. [OK_008@CentOS4 ~] $vi CentOS mytestc.c

# include "stdio.h" int main () {printf ("Hello,this is my first program.\ n");} "CentOS mytestc.c" 5L, 80C written [OK_008@CentOS4] $gcc-o CentOS mytestc-g CentOS mytestc.c recompile [OK_008@CentOS4 ~] $. / CentOS mytestcHello,this is my first program. Success. [OK_008@CentOS4 ~] $

There is no use of gdb debugging tools to adjust the code, and you can make and makefile to complete automatic maintenance compilation work, the function is good.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Compile file learn program system success code mode error help prompt language language programming programming good good-looking clear sloppy professional content Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology macOS Shulou Tech Info Linux