Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how do I use void main in this system for C++

0 votes
asked Mar 16, 2019 by justin means (120 points)

2 Answers

0 votes
answered Mar 20, 2019 by ChillzCodes (140 points)
#include <iostream>

void poo()

{

    std::cout << "poo\n";

}

int main()

{

    poo();

    return 0;

}
+1 vote
answered Mar 20, 2019 by Dion Houston (240 points)
If I understand your question correctly, you're asking how do you have a main function in C++ that returns void. (i.e.)

#include <iostream>

void main() {
    std::cout << "Hello, World";

    return;
}

Short answer - you don't.  C++ requires main() to return an int.  To be honest, even when C "allowed" it, the app still returned an error code.  It was just always 0.  This is functionally equivalent to what a void function did in C:

#include <iostream>

int main() {
    std::cout << "Hello, World";

    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...