---
title: "What is the difference between void main and int main in C/C++?"  
description: "What is the difference between void main and int main in C/C++?"  
author: "Utpal Vishwas"  
published: 2023-07-07  
updated: 2023-07-10  
canonical: https://www.mindstick.com/forum/159002/what-is-the-difference-between-void-main-and-int-main-in-c-c-plus-plus  
category: "visual c++"  
tags: ["c++", "programming language"]  
reading_time: 2 minutes  

---

# What is the difference between void main and int main in C/C++?

What is the [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between void main and [int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql) main in C/[C++](https://www.mindstick.com/blog/745/array-in-c-plus-plus)?

## Replies

### Reply by Aryan Kumar

In C++, the `main()` function is the entry point for all C++ programs. It is the first function that is called when the program starts executing. The `main()` function can have two different return types: `void` or `int`.

- `void main()` indicates that the `main()` function does not return any value. This is the most common way to define the `main()` function.
- `int main()` indicates that the `main()` function returns an integer value. This value can be used by the operating system to determine the status of the program. For example, if the program terminates normally, the `main()` function will return the value `0`. If the program terminates abnormally, the `main()` function will return a non-zero value.

It is important to note that the `main()` function must always have a return type. Even if you do not want the `main()` function to return any value, you should still use the `void` return type.

Here are some examples of how to define the `main()` function:

C++

```plaintext
// void main()
void main() {
  // Do something
}

// int main()
int main() {
  // Do something
  return 0;
}
```

In general, you should use `void main()` unless you have a specific reason to use `int main()`.


---

Original Source: https://www.mindstick.com/forum/159002/what-is-the-difference-between-void-main-and-int-main-in-c-c-plus-plus

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
