Getting started in C

I know that there are many tutorials to get started on C. However, it is difficult for me to use this knowledge. The way I always started in languages ​​is to write scripts. Of course, C is not a scripting language.

My question is not so much in learning C, but how to start applying C. Great. I can write a temperature converter or text rpg. Maybe because in python I will just write the code in somefile.py and chmod + x somefile.py && & somefile.py. I actually don't have an equivalent process for C. Each time I read about C, it is a different compilation process with different flags. Can someone give me a certain direction regarding the best ways to use C when you are already working with higher-level dynamic scripting languages?

Btw ... I am asking about C, not C ++.

I usually use OpenSuse 11 or Ubuntu 9.04. "Which compiler I use" is part of the problem. In python there is no choice of it simply "python somefile.py", the same with php or ruby. I did not know that there was a choice.

+7
c
source share
6 answers

As rogeriopvl writes in a comment, the compilation process is really simple. Just write the code in somefile.c and

gcc -o somefile somefile.c && ./somefile 

(if you use GCC, and if not, then your select compiler can probably be called in a similar way). Until / until you start dealing with more complex projects, it will be hardly more complicated than the scripting language. (Well ... well, you might need to link some libraries as soon as you go beyond the basics. But still, not a huge deal.)

In fact, I wrote myself a small script shell that allows me to use C as a scripting language. But the process of setting it up is a bit more complicated than you might want at this stage - it's easier to just run the compiler every time. However, if you're interested, I can look at directions (for Linux) and put them here.

+4
source share

write wc

 #include <stdio.h> int main(int argc, char *argv[]) { int i; for (i = 0; i < argc; ++i) { printf("Param %d is '%s'\n", i, argv[i]); } return 0; } 

and compile with

 gcc -Wall -ow wc 

run

 ./w 
+5
source share

C code must be compiled before the program starts. The exact process depends on which platform and compiler you are running.

For the most part, using an IDE (such as Visual studio , Eclipse , MonoDevelop, and many others) will do the troublesome job for you, so you just need to click a button or click an icon. Download one of these

+2
source share

I asked myself this question when I was studying C. The problem here, if I can say that this is a problem, is that C can be used in a wide range of applications and in a wide range of environments, its own IDEs or compilers and libraries. Some examples where you can use C for real employees.

Embedded software. In this case, you are likely to use some lib.

Network Programming (see this book .

Device driver development.

Libraries (both for Linux / Windows, and for other OS)

Well, this list is endless.

O do not know if you will help you with this question. If you give more details about what interests you, it may be useful

Good luck.

+2
source share

The best advice I can give here is to find a topic that interests you, see if you can make a program to do what you want / help do what you want / add functionality to your interest, and start coding.

This gives you a bonus to do what interests you, and at the same time do something that directly affects it. This should give motivation to continue to soar along with the learning process.

0
source share

I currently work with C with Linux kernel modules and am new to C. I have found this reward, which, in my opinion, is important for this type of “temperature converter” or text rpg '.

I am also trying to find application of programming skills. I think the balance of challenge and reward is important.

0
source share

All Articles