A statement in C programming language is an instruction for the computer to perform a task. The statements of C programming language are written in curly brackets like "{" "}". Computer performs these instructions one by one in the same sequence in which these instruction are written. Each statement in C programming language is terminated with semicolon ";"
Example of C Programming language statements:
The following example contains two statements in the body of the main() function.
#include
void main ()
{
printf("Welcom to learnunixc-programming.blogspot.com");
printf("Welcom to Learn C / C++ Unix C Programming Language");
}
learn unix c programming language now. Start from today and learn c c++ and unix c programming languages. unix c
Your use of 'void main()' is problematic. 'main()' should always be defined as either 'int main(void)' if your program doesn't take any arguments, or 'int main( int argc, char **)' if it does take arguments.
ReplyDeleteAccordingly, your program must also return an integer value, 0 on success, or non-zero on failure (thus allowing you to pass back different error codes for different modes of failure).
If you do not return an integer, anyone who is trying to run your program within a script will be unhappy. Let's say that you have written a program called 'xyzzy'.
The following should work on the command line in either windows or Unix:
xyzzy && echo "xyzzy worked"
if xyzzy succeeds, you should get a message echoed to the screen that says "xyzzy worked"
... Unless you didn't define main() to return an integer.
Don't make people who write scripts based on your C code curse the day that you were born. Return good integer values from your code.