Call Int32 Function From Main

I am learning C++ and I want to run a method, it doesn't have a return type or need any params passed to it. It just "does the work" from my main method. The issue I am having is it is int32 and not a void method. How would I call this method?

1
2
3
4
5
6
7
int main(int argc, char *argv[])
{
    DOMath();
}
int32_t DOMath() {
    //Code here
}
Hello miketheknight2016,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
// Others if needed.

int main(int argc, char *argv[])
{
int32_t returnValue{};

    returnValue = DOMath();
}

int32_t DOMath()
{
    //Code here

    return variable;
}


Hope that helps,

Andy
closed account (E0p9LyTq)
You can call the function just as you did in line 3, unless you need to deal with the returned value from the function. Then you do as Handy Andy as done.

You need to return some value in your function since you specified a return type. Even if the returned value is just some junk value, such as zero.
Topic archived. No new replies allowed.