Guys, some of you are expert and some still learning C...but anyway can someone write some ideas about how could i learn C? I have to lean it...but i don' t know how!!! waiting...
Guys, some of you are expert and some still learning C...but anyway can someone write some ideas about how could i learn C? I have to lean it...but i don' t know how!!! waiting...
Here's a couple of similiar but different tutorials:
C Programming Tutorial
The GNU C Programming Tutorial
Pick one of those and start working thru it.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
I already have a book in C, but it is difficult...does any know how many months sb need to learn C with normal programing in the pc?
That depends. If you already have some experience in another (reasonably similiar) programming language, so you understand what functions and loops and arrays are, then you may be able to learn the basic syntax inside of a few weeks to a month.
Outside of that, it really depends how much time you put in and how hard it is for you to grasp things like arrays, loops, and functions.
My advice is to write lots of short experiments. Programming tends to involve a lot of typing so you might as well get used to it. If your editor/IDE does not have a feature which can do this automatically, you might want to create a file like this:
Call it "base.c" or something, and then everytime you want to try a fresh snippet of code, just copy that to a new file and go to work. When you have a concept or command figured out, write short simple examples demonstrating the concept, and save those with some comments under a self-explanatory name. For example:Code:#include <stdio.h> int main(int argc, const char *argv[]) { return 0; }
Code:#include <stdio.h> #include <stdlib.h> /* fileread.c: reads a text file named on the command line * and prints it to the screen */ int main(int argc, const char *argv[]) { FILE *in; char buffer[1024]; /* check for argument */ if (argc < 2) { puts("Filename required!"); return -1; } /* try to open file */ in = fopen(argv[1],"r"); if (!in) { perror("fopen() failed: "); return -2; } /* read and print out */ while (fgets(buffer,1024,in)) printf("%s",buffer); /* close file */ fclose(in); return 0; }
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
OK. Create a new text file. Type the following into the text file.
Save the text file as "hello.c". This is called "source code". It's a computer program that humans can read and edit. To run the program, we need to compile it. It's best to use Linux or Mac OS X to program, since they both have a built-in C compiler. Compile the source code in the Terminal. Navigate to where hello.c is saved. Type, "gcc -o hello hello.c". This will create an executable using hello.c. To run the executable, type "./hello". Your program will run, printing "Hello World!" right there, on the screen. Whenever you want to edit your source code, make sure you delete the old executable before you compile a new one.Code:#include <stdio.h> int main() { printf("Hello World!\n"); return 0; }
Here's a good book to begin learning C.
http://www.amazon.com/Programming-La.../dp/0131103628
Actually i am working on C for about 6-7 months...now i try to learn about files, stucks...but i found them very difficult...Should i worry, or they are not very difficult as i think????
Structs are pretty important. Try and write a program using opendir(), readdir(), and stat() to read all the files in a directory and print out their name and size. This involves using some structs, and reading data in loops, probably with a short function to stat() the file and print out information. You get the name of each file from the struct dirent returned by readdir():
You can then take the d_name field and get a bigger struct of file information using stat:Code:struct dirent { char d_name[]; [......]
I am not sure if this is exactly the same on windows -- you should maybe put your OS and the compiler you are using in your signature here.Code:struct stat info; stat("filename",&info); printf("Size: %d bytes\n", (int)info.st_size);
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Well, i am using a partition..so i ave both ubuntu and windows 7...i believe i am totally covered
Yes, it's a source file, and no, it isn't a computer program.
It is a human-readable file. That is all.
You have no program. All you have are source files.To run the program, we need to compile it.
You need a tool that takes your source code and produces a program from it. That is a compiler.
It is NOT best to use Linux or Mac. The operating system has nothing to do with your code. There is no such thing as best. There are compilers for almost all platforms.It's best to use Linux or Mac OS X to program, since they both have a built-in C compiler.
You only need to use the one you are most familiar with.
Unnecessary.Whenever you want to edit your source code, make sure you delete the old executable before you compile a new one.
As for the whole learning thing:
There is a simple path of learning a language. This path is basically:
- Read one or more beginner books.
- Read one or more immediate books.
- Read one or more expert books.
- Practice, practice, practice.
There is no easy way to become an expert in any language in any short amount of time and there are not shortcuts. Learn from books, tutorials and other resources. Ask if you don't understand. Assimilate all the information from the books. Do this by doing exercises with what you just learned.
Then write programs, programs, programs and many more programs.
All the experts on this board have become experts because they've been writing code for many, many years. You can do it, too, and you'll notice that your knowledge will grow, and one day, you, too, will be an expert.
But also note that it isn't possible to learn everything. Even experts have things they don't know.
Um... get confirmation from another party. IDE's make it unnecessary most of the time, but even so, sometimes you have to clean projects; if you're a minimalist, it has to be done. I think so, anyway. Makefiles probably do some magic, but I don't know.Unnecessary.Whenever you want to edit your source code, make sure you delete the old executable before you compile a new one.
No recommendations?- Read one or more beginner books.
- Read one or more immediate books.
- Read one or more expert books.
Well, mostly agreeable, but you're allowed to specialize. And there is a keen difference between not knowing and memory lapses. [/hand-waving]But also note that it isn't possible to learn everything. Even experts have things they don't know.