C语言 我如何在家练习 C 编程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2871160/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I practice C programming at home
提问by cnovice
I've took C programming class while back ago. Since I'm done with the class and don't have any access to the school lab anymore, can anybody give me suggestion how do I practice my c at home. Thanks
前段时间我上过 C 编程课。由于我已经完成了课程并且不再有任何机会进入学校实验室,任何人都可以给我建议我如何在家练习我的 c。谢谢
回答by Michael Dorgan
Code a little game like tic-tac-toe or pong. Lots of fun and a sense of accomplishment when you are done, but complex enough to keep you working at it for a while :)
编写一个像井字棋或乒乓球这样的小游戏。完成后会有很多乐趣和成就感,但复杂到足以让你坚持一段时间:)
There are also code competition sites like topcode at google and such to keep practiced. Heck, code kata could help as well. Like playing an instrument, you must keep practicing to get better. Ideally, you'd get an entry level / internship position to further improve your abilities under a mentorship.
还有一些代码竞赛网站,如 google 的 topcode 等,可以不断练习。哎呀,代码卡塔也可以提供帮助。就像演奏乐器一样,您必须不断练习才能变得更好。理想情况下,您将获得入门级/实习职位,以在指导下进一步提高您的能力。
If you lack a compiler, microsoft has a free version of the latest dev studio available for download. It can do c, c++, c# and anything in between. Also, the suggestion of gcc is a good one as it is widely used in various open source developments over at source forge - another place to go and sign up for a project and help out a group project.
如果你没有编译器,微软有一个免费版本的最新开发工作室可供下载。它可以执行 c、c++、c# 以及介于两者之间的任何操作。此外,gcc 的建议是一个很好的建议,因为它被广泛用于 source forge 的各种开源开发中 - 另一个可以去注册项目并帮助团队项目的地方。
回答by Stellios
Try solving some ACM programming contest problems using C.
尝试使用 C 解决一些 ACM 编程竞赛问题。
Writing code for the judge and submitting it is lots of fun.
为法官编写代码并提交是很有趣的。
回答by Wai Yip Tung
I assume you have a computer at home. Is your question about access to software? If it is Mac or Linux, then it already has a gcc compiler. For Windows, you can download mingw or cygwin. I believe Microsoft also have a free version of it Visual C++ for download.
我假设你家里有一台电脑。您的问题是关于软件的访问吗?如果是 Mac 或 Linux,那么它已经有了 gcc 编译器。对于 Windows,您可以下载 mingw 或 cygwin。我相信微软也有免费版本的 Visual C++ 可供下载。
回答by ohho
The first c exercise I had fun with is solving a maze. A maze looks like this
我玩的第一个 c 练习是解迷宫。迷宫看起来像这样
********** 0
* * *B * 1
* * **** * 2
* * * * 3
* * * ** * 4
*A * * 5
********** 6
0123456789
so on a 10 x 7 array, Ais the staring point (column 1, row 5) , Bis the destination. *is wall and spaceis road. The objectiveof the program is to print every coordinates of the shortest path from A to B, e.g. 1,5 -> 2,5 -> 3,5 -> 3,4 -> ...
所以在一个 10 x 7 的数组上,A是起点(第 1 列,第 5 行),B是目的地。*是墙,space是路。该程序的目标是打印从 A 到 B 的最短路径的每个坐标,例如1,5 -> 2,5 -> 3,5 -> 3,4 -> ...
if you are looking for a compiler, MingGWis free on Windows.
如果您正在寻找编译器,MingGW在 Windows 上是免费的。
回答by David Cournapeau
Your question may be understood in several ways:
您的问题可以从以下几个方面来理解:
You don't know how to have an environment to deal with C at home
你不知道家里怎么有环境对付C
This is partly a matter of opinion, but especially for C, I think linux is a good environment. C and Unix are tied together after all. You will need gcc, make, etc... I remember when I started learning C as my first programming language at school, nothing made much sense (separate compilation, linking, make, etc...), and I don't know where you at there.
这部分是见仁见智,但尤其是对于C,我认为linux是一个很好的环境。毕竟 C 和 Unix 是联系在一起的。您将需要 gcc、make 等……我记得我在学校开始学习 C 作为我的第一门编程语言时,没有任何意义(单独编译、链接、make 等……),我不知道你在那里。
You want a project to practice C at home
你想要一个在家练C的项目
I will assume you know how to use a typical environment to build C software. I think the best is to get into an open source project. C is a widely used language in open source, and finding a project which is both interesting to you and in need of manpower should not be difficult. Starting a project from scratch is what you do at school, and getting into a "real" project will make you learn much more useful thing than doing the same thing at home - dealing with source control, dealing with bug tracking, dealing with people :) There is a steeper learning curve, if only to get involved in the project proper, but I think it is much more rewarding, especially if it is a widely used project.
我假设您知道如何使用典型环境来构建 C 软件。我认为最好的方法是进入一个开源项目。C是开源中广泛使用的语言,找到一个既感兴趣又需要人力的项目应该不难。从头开始一个项目是你在学校做的事情,进入一个“真正的”项目会让你学到比在家里做同样的事情更有用的东西——处理源代码控制、处理错误跟踪、与人打交道: ) 有一个更陡峭的学习曲线,如果只是为了适当地参与项目,但我认为它更有回报,特别是如果它是一个广泛使用的项目。
C is usually used for low level stuff, but besides obvious (and rather difficult) things like the kernel, there are language runtimes (diving into Python C code for example is not too difficult), audio/video editors (ardour, etc...), etc...
C 通常用于低级的东西,但除了像内核这样明显(而且相当困难)的东西之外,还有语言运行时(例如深入研究 Python C 代码并不太难)、音频/视频编辑器(ardour 等。 。), 等等...
回答by Pieter Germishuys
The best way to learn a programming language is to use it. Many times at home you sit there and realize that there is some utility that you could write that will make your life easier.
学习编程语言的最好方法就是使用它。很多次在家里,您坐在那里并意识到您可以编写一些实用程序,这将使您的生活更轻松。
I don't recommend coding games that require an API or such as it will just confuse the matter. You would ideally like to learn the language a bit better before attempting to learn a Graphics API.
我不建议编写需要 API 之类的游戏,因为它只会混淆问题。理想情况下,在尝试学习图形 API 之前,您希望更好地学习该语言。
回答by Chris
Supplementing the other answers, if you're on a beefy Windows machine you can run something like Ubuntu in a virtual environment like VirtualBoxto get a sandbox that's built to run C programs.
补充其他答案,如果您使用的是强大的 Windows 机器,您可以在VirtualBox等虚拟环境中运行 Ubuntu 之类的东西,以获得一个专为运行 C 程序而构建的沙箱。
回答by Cheery
Install ubuntu or debian. After installation do:
安装 ubuntu 或 debian。安装后执行:
sudo aptitude install gcc
Or alternatively install some other C compiler.
或者安装一些其他的 C 编译器。
Now you're capable of compiling C source code to binary which you can run.
现在,您可以将 C 源代码编译为可以运行的二进制文件。
Consult the manual of your compiler for usage and learn how to write shell scripts for constructing build-scripts.
查阅您的编译器手册以了解用法并学习如何编写用于构建构建脚本的 shell 脚本。
回答by David Z
Just write and run C programs at home, how else would you practice? ;-)
就在家写和运行C程序,你会怎么练习?;-)
I suspect that, although you didn't say so, you're wondering about how you can get the necessary tools to compile a C program on your own computer - am I correct? If that's the case, know that all the tools you need to develop C programs are available online for free. The most important is a compiler, of course, and one of the most popular compilers is GCC. If your computer runs Windows, I thinkyou can also download Microsoft's Visual Studio for free (or some edition of it, at least), and I believe that would include a C compiler.
我怀疑,虽然您没有这么说,但您想知道如何获得在您自己的计算机上编译 C 程序所需的工具——我说得对吗?如果是这种情况,请知道开发 C 程序所需的所有工具都可以免费在线获得。最重要的是编译器,当然,最受欢迎的编译器之一是GCC。如果您的计算机运行 Windows,我认为您还可以免费下载 Microsoft 的 Visual Studio(或至少是它的某个版本),我相信其中会包含一个 C 编译器。
You'll also need an editor or IDE. At a bare minimum you could do it in Notepad, but that's inflicting unnecessary pain on yourself. Notepad++is a popular alternative that's good for programming. Or if you're using Visual Studio, that has its own editor. (Actually VS has pretty much everything you need, as far as I know - I haven't used it much myself)
您还需要一个编辑器或 IDE。您至少可以在记事本中完成此操作,但这会给您自己带来不必要的痛苦。Notepad++是一种非常适合编程的流行替代品。或者,如果您使用的是 Visual Studio,则它有自己的编辑器。(实际上 VS 几乎拥有你需要的一切,据我所知 - 我自己并没有经常使用它)
回答by gimel
See c-on-visual-studiofor discussion of the Windows environment. Microsoft provides a free version of visual studio, Visual C++ 2010 Express.
有关Windows 环境的讨论,请参阅c-on-visual-studio。Microsoft 提供了VisualStudio 的免费版本Visual C++ 2010 Express。

