Pages

Of Computers, troubles and my Experiments with programming as a beginner.

Wednesday, March 26, 2008

conio.h Header

Conio.h is yet another header file. It is however, not a part of the C standard library and does not find place among the 24 ANSI C library headers. It is mainly used for console input,output. The Dev C++ compiler does not have this header by default and it has to be separately downloaded if required. It is not very popular actually.
Some of it's important member functions are kbhit, ungetch, getch, getche, putch and some more.
I primarily use getch function for the output to display on the console. It's actually the easiest way. Otherwise, what happens is the console window closes immediately after the output is displayed. In a program where a few inputs are required from the user, this might not be of immediate concern. However, even then you will not be able to visualise the final output. There are other ways of doing the same. We shall cover that later.
So the console now waits for you to press a key on your keyboard. Till then, you can sit and marvel at the output of your program. :)

Sunday, March 23, 2008

Stdio.h Header

stdio.h is the most commonly used header file in the C programming languge. It is used with a #define pre-processor compiler directive which is placed before the main() function.
It stands for standard input/output header. It is a part of the standard library and one of the 24 headers recognised in ANSI C. It contains some macro definitions, constants and delaration of functions.
Some of the functions include fclose , fopen , freopen , fdopen, remove , rename , rewind , tmpfile , clearerr , feof , ferror, fflush, fgetc, fgets, fputc, fputs, ftell, fseek, fsetpos, fread, fwrite, getc, getchar, gets, printf, vprintf, fprintf, vfprintf, perror, putc, putchar, fputchar, scanf, vscanf, fscanf, vfscanf, sscanf, vsscanf, setbuf, setvbuf, tmpnam, ungetc, puts.
In addition to the function delarations, it also has member constants and member variables.

Thursday, March 20, 2008

Printf() Function

printf() is a very commonly used funtion in C language. This is replaced in C++ by the cout, which is easier to write for a programmer. But printf() gives you control over the data type of the variable that you use. It writes to the standard output stream. It is contained in the C standard library. It can sometimes be used without having to include any header files. However, in some old compilers, it is found that stdio.h is to be included to be able to use printf.
printf stands for print formatted. The data type control can be achieved by means of format specifiers which are as follows,
%d for integers
%f for float
%u for unsigned integer
%e for double
%c for character
printf() has a syntax as follows:
printf("string" %d,variable);
the %d here in this syntax is an example. It can be replaced by other format specifiers.

Monday, March 17, 2008

Choosing a Compiler

When you get started with programming, it is enough to start with pen and paper approach. (Or, pencil and paper approach ;) if you like it.) In fact, I'd recommend this. This way, you are placing more emphasis on the logic rather than the nuances of your compiler. If you get started with programming on your computer directly, then error messages can be a distraction. So,I'd always recommend that we start out without actually trying to compile and execute a program. We shall do that in due time, but not just yet.
Once you get the basics of programming and are ready to code using the computer, then you need to choose the right compiler for you. If you plan to use C and then later on upgrade to C++, then Dev C++ is a natural choice. It's strong, it's user friendly and what's more, it's FREE. If you have facilities available at your place of education or something like that, even VC++ by Microsoft might be a good option as long as you can afford it.
For people who want to use only C, I'd still recommend Dev C++ because I hate using the Turbo C and the Borland C compilers. No, it's not just that I hate it. Loads of people hate it. These compilers are ancient and act up frequently. I am sure many people will still be ardent fans of these and I mean no disrespect. In their day and age, they were pretty good. But it's time we move on.

Thursday, March 13, 2008

A Brief Message...

What's this post about ? I have a blog dedicated to programming where I shall try and provide some information for people who don't know much of programming. But how do I go about doing that ? That's going to be addressed in this post.

For starters, this is not a replacement for books and is most definitely not meant as a substitute for books. It's meant to supplement the contents of the books. Also, if you are looking for quick help on syntax or things like that, this is definitely not the place you'd like to land in. However, if you have read and re-read books over and over again and still don't get what's being said or are not able to write your own program, then welcome. :)

I shall take some programs that will demonstrate some concepts of programming and try and explain the whole process, right from tackling the problem to writing the code to debugging and then finally making it work.

Sunday, March 9, 2008

Book: Let Us C by Yashwant Kanetkar

Let Us C by Yashwant Kanetkar is one of the most widely used books by Indian students who learn C programming. It is highly recommended by most people who have used it and gained from it. I have used the book myself and found that the exercises are quite challenging. Another feature about this book that I did not find in the Programming in ANSI C by Balagurusamy is that it had a couple of extra things that you will be using in real life. Such as,
  • C under Windows - something we should know to create real life applications in windows
  • Graphics under Windows - doesn't hurt to know that either.
  • Internet Programming -I haven't tried this out yet, but I am sure it's going to be interesting.
  • C under Linux
  • More Linux Programming

Thursday, March 6, 2008

Programming with C-Books

There are some great books available on how to get started on C Programming. For someone like me, who did not know programming till I was into college, getting started with a good book is of great importance. Here are some of the books that are in my opinion good, for a beginner:
  • Programming in ANSI C by E Balagurusamy (Well, this book is written by an Indian author and not many people might have heard of it. But then I started out with this book and have found it to be awesome.)
  • Let Us C by Yashvant Kanetkar (Again an Indian author. Supposed to be a good book. I have never used this book all that much, but it has some stuff that are considered really good.)
  • Programming with C by Byron Gottfried (An excellent book for C, but then, if you don't know your C, don't get started with this book. Once you have achieved basic proficiency, it's a good idea to start out with this book.)
  • C for Dummies by Dan Gookin (A very well written book that is also funny. :) )
  • C Programming by Kerninghan and Ritchie (A book, I have never used but have heard is excellent.)

Pick the book of your choice. In the end, it doesn't really matter which book you chose, as long as you know your programming fundamentals.If you learnt C from another book and think it was nice and easy to learn with, then do let me know.

Monday, March 3, 2008

About

Hi all. I am an engineering student. Although I am not a Computer Engineer myself, I love programming and experimenting as such. I would consider myself an average programmer who is capable of writing simple programs.
I am no programming guru though and cannot work magic with programs. But then being who I am, I felt that I can be of immense help to people like me-beginners who are interested in programming.
I love using C and somehow liked C++ even better. I am very new to Java and haven't explored the many possibilities just yet. Yet, I am sure I will continue learning.