I typed this program exactly as it is in the textbook by: Robert Lafore
it gives the following errors:
C:\Dev-Cpp\Functions\beeptest.cpp In function 'int main()':
8 10 C:\Dev-Cpp\Functions\beeptest.cpp [Error] 'twobeep' was not declared in this scope
10 9 C:\Dev-Cpp\Functions\beeptest.cpp [Error] 'getche' was not declared in this scope
C:\Dev-Cpp\Functions\beeptest.cpp At global scope:
16 10 C:\Dev-Cpp\Functions\beeptest.cpp [Error] ISO C++ forbids declaration of 'twobeep' with no type [-fpermissive]
16 10 C:\Dev-Cpp\Functions\beeptest.cpp [Error] ISO C++ forbids declaration of 'twobeep' with no type [-fpermissive]
The function needs a return type. If it doesn't return any value the return type should be void.
1 2 3 4
void twobeep()
{
...
}
8 10 C:\Dev-Cpp\Functions\beeptest.cpp [Error] 'twobeep' was not declared in this scope
The function needs to be declare before you can use it. You either have to define the twobeep function above main, or you could just declare it above main and leave the definition below main.
10 9 C:\Dev-Cpp\Functions\beeptest.cpp [Error] 'getche' was not declared in this scope
getche is a non-standard function that came with some old compilers. You could try including conio.h but if that doesn't work you'll have to use something else.
1 2 3 4 5 6 7
int main()
{
twobeep();
cout << "Press enter to continue!";cin.ignore(100, '\n');
twobeep();
}