Wednesday, January 4, 2012

Will the follow C program work correctly?

main()
{
printf("This is C!");
}


It may. However, this depends on your compiler. The reason it may work is that;

1) This file stdio.h is used so frequently in C that, for some compilers, it is attached automatically to programs despite no specific direction to do this.

2) Even though you have not written "void main(void)"-that is, the voids are missing-C assigns default types for the voids. The word default is used commonly in computing. A default value is a value that is used when none is specified. Without going into detail, because C assigns default types for missing voids, this program may work. However, I would not recommend that you write your programs in this manner.

No comments:

Post a Comment