开发者

How do I practice C programming at home [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

开发者_高级运维

Closed 4 years ago.

Improve this question

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


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.

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.


Try solving some ACM programming contest problems using C.

http://acm.uva.es/

Writing code for the judge and submitting it is lots of fun.


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.


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.


The first c exercise I had fun with is solving a maze. A maze looks like this

********** 0
* *  *B  * 1
* * **** * 2
* * *    * 3
* * * ** * 4
*A    *  * 5
********** 6
0123456789

so on a 10 x 7 array, A is the staring point (column 1, row 5) , B is the destination. * is wall and space is road. The objective of 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 -> ...

if you are looking for a compiler, MingGW is free on Windows.


Your question may be understood in several ways:

You don't know how to have an environment to deal with C at home

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.

You want a project to practice C at home

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 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...


Just write and run C programs at home, how else would you practice? ;-)

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 think you 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.

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)


See c-on-visual-studio for discussion of the Windows environment. Microsoft provides a free version of visual studio, Visual C++ 2010 Express.


Supplementing the other answers, if you're on a beefy Windows machine you can run something like Ubuntu in a virtual environment like VirtualBox to get a sandbox that's built to run C programs.


Install ubuntu or debian. After installation do:

sudo aptitude install gcc

Or alternatively install some other C compiler.

Now you're capable of compiling C source code to binary which you can run.

Consult the manual of your compiler for usage and learn how to write shell scripts for constructing build-scripts.


Begin with solving basic level logical questions, and while solving always follow the best approach and best practices.

You can refer and try solving these fundamental question : C programs

Also try solving questions of : Project Eulers


A really good way to exercise C is to read (or reread) The C Programming Language (K&R) and to do every exercise at the end of each chapter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜