【C++】[Error] ‘::main‘ must return ‘int‘

tags: Bug collection  c++  c language

Error map:

wrong reason:

The C language standard allows the main function to be of type void. According to the C++ standard, main must be of type int
devc++ is not allowedvoid main Appeared

Solution:

Willvoid Deleteor Willvoid Toint

Intelligent Recommendation

C ++ int main (int argc, char * argv [])

1. Explanation of parameter meaning The argc and argv parameters are useful when compiling programs on the command line. main( int argc, char* argv[], char **env ) in: The first parameter, int-type ar...

The function template problem in C ++, unexpected harvest, the main function can only return int?

The C ++ 11 standard adds a: main function must return int? I didn't pay attention to this problem before. I want to change an environment today. When using vscode, I found that Void main didn't pass,...

The difference between "int main ()" and "int main (void)" in C / C ++

Consider two definitions of main (). and What's the difference? In C ++, there is no difference, the same. These two definitions are also applicable in the C language, but the second definition with V...

C Language: Void Main or int Main?

Article translation transferred from:https://users.aber.ac.uk/auj/voidmain.cgi Void Main (Void) - Incorrect usage News Group comp.lang.c Almost continuously discusses whether we can use Void as the re...

C ++ use void main () or int main ()?

First, clarify three points: 1: The process under Linux will have a return value, range [0 ~ 255], int main () is to correspond to this return value. 2: Use int main () mainly to return a value to the...

More Recommendation

The C language not all control paths return a value error and the int function has more return value problems

After writing the code today, I found that there was no return value in the logic, but the function (required to have a return value) ran successfully. After researching, I found that the specific rul...

What is the difference between int main(), void main(), int main(void) and void main(void) in C/C++

One, the main function is also a function First of all, we need to understand the definition of functions in C/C++, because the main function is also a function. The difference from other functions is...

Must the main function have a return value?

forward from Let’s talk about the C99 regulations, main needs a return value. Two forms are allowed, one with parameters and the other without parameters. Among them, argv can be written as char...

The specific meaning of int main(int argc,char *argv[]) in c/c++

Blog from ajioy:   The specific meaning of int main(int argc,char *argv[]) in c/c++ int main(int argc,char * argv[]) Argv is a pointer to a pointer Argc is an integer   char **argv or: char ...

C ++ Stack Pop () Return Value Error: Cannot Initialize A Variable of Type 'Int' with an Rvalue of Type 'Void'

LeetCode listing inverted topic When you use the stack stack's POP (), write it at first Error: Cannot Initialize a Variable of Type 'int' with an rvalue of type 'void' Because POP () is only responsi...

Copyright  DMCA © 2018-2023 - All Rights Reserved - www.programmersought.com  User Notice

Top