Compiler Error Messages

Hi, my name is BedaBing. I've read a lot of the beginner forums here when I have needed help. This will be my first time posting on here because I was not able to find the solution I was looking for.
What I am trying to do in the program below is call out the functions, however I am having issues with this error message which states 'expected init-declarator before "void" '. I can't seem to find a way to properly fix it. Also in line 11 it states; expected primary-expression before "void". If you guys could point me in the right direction that would be amazing, I've spent the greater part of today attempting to work it out and it has left my mind boggled.


#include <iostream>
#include <cstring>
using namespace std;
void LengthofTime(int time);
void MrSmith();
int RunningTime(int x);

int main()
{
cout << "With only a string argument" << endl;
cout << void LengthofTime(int time) << void MrSmith() << "Running time" << int RunningTime(int time) << "minutes." << endl;
system("PAUSE");
return 0;
}
void LengthofTime(int time)
void int time = 100
{
switch (time)
{
case 80:
cout << "Wrong Time" << endl;
break;
case 101:
cout << "10 minutes off" << endl;
break;
default:
cout << "CasaBlanca. Running Time 90 minutes." <<endl;
return y
}
}
void MrSmith()
{
cout << "Mr.Smith Goes to Washington." << endl;
}
int RunningTime(int x)

int x = answer
{
int answer = 110
return answer

}
Last edited on
If this is a troll, ... damn that's ..magical. Amazing.
If this is for real, please completely start over from the beginning with "Hello, world!" and work from there because, dang, you have some major misconceptions about the syntax of C++. This is beyond helping, there are more errors there than I can even count.
Okay, thanks I'll start over with the code. I noticed that I added the switch statement totally wrong lol aside from like you said it being all wrong. I will just delete and restart the code. Do you know of an article or link that explains what all the compiler errors mean, or does it just come with experience the meaning of them?

If you need help understanding compiler diagnostics, please post the exact diagnostic messages.

No need to start over, but there are a number of things you need to fix:

Here are the problems I see:

Line 11:
 
cout << void LengthofTime(int time) << void MrSmith() << "Running time" << int RunningTime(int time) << "minutes." << endl;

You can call functions in a cout statement as long as the function returns something cout understands. You can't however call a void function in a cout statement since it doesn't return anything. Also, when you call a function in a cout statement, you don't include the type of the function. The compiler knows the type of function from where you declared it.

Line 15:
1
2
3
void LengthofTime(int time)
void int time = 100
{

Not sure what you're tring to do there. You can't declare a variable between the function header and the opening brace. Also void int makes no sense.

Line 18: I don't understand what you're trying to do with the switch statement.

Line 28: You're trying to return y, but y is not defined. Also, LengthOfTime is declared as a void function, so it's not legal to return anything.

Line 35:
1
2
3
4
int RunningTime(int x)

int x = answer
{

Again the same problem trying to declare something between the function header and the opening brace.

PLEASE USE CODE TAGS (the <> formatting button) when posting code. It makes it easier to help you.



Last edited on
Okay thanks a lot. I looked it all over and was able to fix the code, thanks for the tips
Topic archived. No new replies allowed.