Hello everybody, I am new to C language and I ve fallen in love with it. I would like to do allsotrs of things with C, from high level to low stuff like programming microcontrollers. My question is on the main function and the return statement. Why is int included at the beginning of the main function even though the function is not returning an interger: int main () { printf("Hello World!\n"); return 0; } This function returns a strings and why do we have to include the int? Secondly whats the purpose of the return 0;? When do we use void?
sir when we are using void in our program it means that we are not returning anything to our required function i,e.., void main() { printf("cfanatic); } void ,int ,char,float before main are called as return type it means that if we use int as return type in our program int main() { printf("CFANATIC"); return 0; //since we have mentioned return type as int we should return int value to function }
Thank you. Give me a function that returns something. Isn't contradictory for an int main () function to have a return 0; at the end?
that is not a contradictory since u have mentioned return type as int u have to return something otherwise it would be warning when u compile in turboc as "Function should return a value"