ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
hey guys i wanted to learn c programming in linux.... but all the tutorials and books are based on windows
that was the first program i did with bcc32 compiler in windows.... what shuld i do for the same in linux....
why choose int mani i dint have any integer values...
It's the standard for writing C prorgrams on UNIX-like OSes (this includes Linux). The return statement at the end of main() spits out a zero to the shell, so that it can be used as, for example, an error code if something goes wrong in the program (invalid input, etc.):
int main(int argc, char** argv)
printf("You entered the right argument! :D\n");
else //If the user gives anything other than the word "something" as an argument
printf("Error, you entered %s instead!",argv);
return 1; //Return an error code. This can be anything,
//as long as it's not 0, as that's the
//standard code for "success".
return 0; //If everything went smoothly, go ahead and return nothing.
If I were to call this program "something", and I ran ./something "something" in the shell, it would return a 0 to the shell, which could be used in for example a shell script to show that the program ran successfully. Had I just ran ./something "nothing" (or anything other than "something", or just no argument at all), then it would have returned a one to the shell, and I could use that in a shell script to show that the program failed.
Gurus, if I missed a few important details, please don't hesitate to provide them. I'm a little tired/sleepy as I write this, so I'm probably not able to concentrate as well as I could.
Last edited by MrCode; 07-10-2010 at 11:32 PM.
Reason: fixed the parentheses around the if statement :-P
/*#include<conio.h> this is not used in linux c programming. because conio.h doesnt exist in linux.*/
//getch(); you cannot use this function because conio.h doesnt exist in linux
} SO what i am coming to say is that you may programmed in turbo c or c++.But Friend a slight different in linux programming.you have understand about following sections for studying linux C programming.
4.Running or Execution.
And understand.... like windows C programming,there is no rules to use specific IDE. you can edit your c programs on any editor. but i heard code::blocks are the greatest C programming IDE in linux. it helps the programmers very well.
Well if you are so so so so so lazy to study the new functions and headerfiles of linux c programming. i will tell you a adventorous trick ways.
enter into the location
you may see many files concern extension header file. just view the headerfile and read the prototypes of functions. just put it onthe program with apropriate specification of header files.
start your programming
PLEASE UNDERSTAND LINUX DOESNT CONTAINS graphics.h HEADERFILE. BECAUSE INSTEAD OF IT. YOU HAVE TO SDL LIBRARY FUNCTIONS.
Int main comes because when you will run a program it should return a status to operating status(Linux),so when you program will become a process it will return a status of it to Linux,whether program worked correctly or not.
second thing for Learning C/C++....you can use Anjuta IDE
People i would like to say that..
Do you think that could your linux box can compile source codes of softwares with perfectly.
if you dont have enough library dependencies then surely you cannot play with open source or hacking
Dont you understand?
hey people please update your libraries.
do you wanna write Graphical user interface programs(gtk libraries)
do you wanna write Ncurses programs (ncurses libraries)
do you write graphics related programs(games) (SDL libraries)
do you wanna write kde based windows(qt libraries)