Join Stack Overflow to learn, share knowledge, and build your career. Connect and share knowledge within a single location that is structured and easy to search. I'm learning C and I'm very new to it, so forgive me for the seemingly stupid question. I have some experience in Java, and I noticed that C programs also need a main method in their main class. What if I want to create a class that isn't a main class, i. I tried to do that, and when I compile via cmd using csc File.
Walkthrough: Compile a C program on the command line
C Examples | Programiz
Step 1 : You write your program and save the file with a. Step 2 : You compile the program and generate the object file using gcc compiler in a terminal like this:. This was just the quick summary on how to compile and run C program in Linux. In order to run a C program in Linux, you need to have a C compiler present on your systems.
Table of Content
C applications have an entry point called Main Method. It is the first method which gets invoked whenever an application started and it is present in every C executable file. The application may be Console Application or Windows Application.
The main is the starting point for JVM to start execution of a Java program. Without the main method, JVM will not execute the program. The syntax of the main method is:. We should use a public keyword before the main method so that JVM can identify the execution point of the program. If we use private, protected, and default before the main method, it will not be visible to JVM.