mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-25 00:50:15 +08:00
translating
This commit is contained in:
parent
e049725ef4
commit
92b6b9102e
@ -1,57 +0,0 @@
|
||||
[#]: subject: "5 ways to learn the C programming language in 2022"
|
||||
[#]: via: "https://opensource.com/article/22/1/c-programming"
|
||||
[#]: author: "Jim Hall https://opensource.com/users/jim-hall"
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
5 ways to learn the C programming language in 2022
|
||||
======
|
||||
With only a little knowledge of C, you can do a lot.
|
||||
![Person drinking a hot drink at the computer][1]
|
||||
|
||||
I am proficient in several programming languages, but my favorite has to be C. Developed in the 1970s as a systems programming language, C remains one of the most popular programming languages in 2021. If you'd like to explore several features of the C programming language, start with these popular articles from the last year:
|
||||
|
||||
[Short option parsing using getopt in C][2]
|
||||
|
||||
You can make your program much more flexible if it responds to the user every time it runs. Let your user tell your program what files to use or how to do things differently. And for that, you need to read the command line. This article shows you how to read the command line directly using `argv` and use short command-line options using `getopt`.
|
||||
|
||||
[Position text on your screen in Linux with ncurses][3]
|
||||
|
||||
Most Linux utilities just scroll text from the bottom of the screen. But what if you wanted to position text on the screen, such as for a game or a data display? That's where `ncurses` comes in.
|
||||
|
||||
[Get started programming with DOS conio][4]
|
||||
|
||||
C isn't just for Linux. You can find C on many operating systems, including DOS. The standard way for many C programmers to control console input and output was with the `conio` library. Learn how to use `conio` to update the console from DOS programs, including text color and text windows.
|
||||
|
||||
[Write a chess game using bit-fields and masks][5]
|
||||
|
||||
The standard way to associate information in a C program is by using a structure that combines two or more related fields. For example, you might use a structure to track chess pieces on a board. But there's a more straightforward way to track the same information while using less data and memory. Using binary bit-fields and masks, you can store a single value to identify the pieces and color in each square.
|
||||
|
||||
[5 common bugs in C programming and how to fix them][6]
|
||||
|
||||
Even the best programmers can create programming bugs. Depending on what your program does, these bugs could introduce security vulnerabilities, cause the program to crash, or create unexpected behavior. But with a little extra code, you can avoid the most common and most serious C programming bugs. Here are five bugs that can break your application and how you can avoid them.
|
||||
|
||||
With only a little knowledge of C, you can do a lot. Explore new ways to add features to your next C programming project.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/1/c-programming
|
||||
|
||||
作者:[Jim Hall][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/jim-hall
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hot drink at the computer)
|
||||
[2]: https://opensource.com/article/21/8/short-option-parsing-c
|
||||
[3]: https://opensource.com/article/21/8/ncurses-linux
|
||||
[4]: https://opensource.com/article/21/9/programming-dos-conio
|
||||
[5]: https://opensource.com/article/21/8/binary-bit-fields-masks
|
||||
[6]: https://opensource.com/article/21/10/programming-bugs
|
@ -0,0 +1,57 @@
|
||||
[#]: subject: "5 ways to learn the C programming language in 2022"
|
||||
[#]: via: "https://opensource.com/article/22/1/c-programming"
|
||||
[#]: author: "Jim Hall https://opensource.com/users/jim-hall"
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
2022 年学习 C 语言编程的 5 种方法
|
||||
======
|
||||
只需掌握一点 C 语言的知识,你就可以做很多事情。
|
||||
![Person drinking a hot drink at the computer][1]
|
||||
|
||||
我精通几种编程语言,但我最喜欢的是 C 语言。C 语言开发于 20 世纪 70 年代,作为一种系统编程语言,在 2021 年仍然是最受欢迎的编程语言之一。如果你想探索 C 语言的几个特点,可以从去年的这些热门文章开始:
|
||||
|
||||
在 C 语言中使用 getopt 进行短选项解析][2]
|
||||
|
||||
如果你的程序每次运行时都能对用户作出反应,你就可以使它变得更加灵活。让你的用户告诉你的程序使用什么文件或如何以不同的方式做事情。为此,你需要读取命令行。这篇文章告诉你如何使用 `argv` 直接读取命令行,并使用 `getopt` 读取短命令行选项。
|
||||
|
||||
[在 Linux 中用 ncurses 定位屏幕上的文本][3]
|
||||
|
||||
大多数 Linux 工具只是从屏幕的底部滚动文本。但如果你想在屏幕上定位文本,比如游戏或数据显示,该怎么办?这就是 `ncurses` 的作用。
|
||||
|
||||
[用 DOS conio 开始编程][4]
|
||||
|
||||
C 语言并不只适用于 Linux。你可以在许多操作系统上找到 C,包括 DOS。许多 C 程序员控制控制台输入和输出的标准方法是使用 `conio` 库。学习如何使用 `conio` 来更新 DOS 程序的控制台,包括文本颜色和文本窗口。
|
||||
|
||||
[使用位域和掩码编写国际象棋游戏][5]
|
||||
|
||||
在 C 语言程序中关联信息的标准方法是使用一个结合了两个或多个相关字段的结构体。例如,你可以用一个结构体来跟踪棋盘上的棋子。但是有一种更直接的方法来跟踪同样的信息,同时使用更少的数据和内存。使用二进制位域和掩码,你可以存储一个单一的值来识别每个方格中的棋子和颜色。
|
||||
|
||||
[C 语言编程中的 5 个常见错误以及如何修复它们][6]
|
||||
|
||||
即使是最好的程序员也会产生编程错误。根据你的程序所做的事情,这些 bug 可能会引入安全漏洞,导致程序崩溃,或产生意外的行为。但是,通过一点额外的代码,你可以避免最常见和最严重的 C 语言编程错误。这里有五个可能破坏你的应用的 bug 以及你如何避免它们。
|
||||
|
||||
只需一点 C 语言知识,你就可以做很多事情。探索新的方法,为你的下一个 C 语言编程项目增加功能。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/1/c-programming
|
||||
|
||||
作者:[Jim Hall][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/jim-hall
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hot drink at the computer)
|
||||
[2]: https://opensource.com/article/21/8/short-option-parsing-c
|
||||
[3]: https://opensource.com/article/21/8/ncurses-linux
|
||||
[4]: https://opensource.com/article/21/9/programming-dos-conio
|
||||
[5]: https://opensource.com/article/21/8/binary-bit-fields-masks
|
||||
[6]: https://opensource.com/article/21/10/programming-bugs
|
Loading…
Reference in New Issue
Block a user