Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

Expected a declaration C++

Delete this thread please, thank you
Here you go:

PHP Code

<?php 
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
inline void keep_window_open() {
    
char ch; cin >> ch;
}

    
int main()         // C++ programs start by executing the function main
    
{        
        
cout << "Hello, World!\n";    // output “Hello, World!”        
        
keep_window_open();           // wait for a character to be entered        
        
return 0;
    } 

You were missing the closing brace for your first function definition.
[Image: npafFhp.gif]
You're defining main inside another function, first off. Apparently this is valid in C++? Dear God someone help me. One line's missing a semicolon according to the topmost issue, and the left brace somewhere isn't matched up, aka there's a brace somewhere that doesn't have a pair. Ex:
Code
{
     somecode;

where it should be:
Code
{
    somecode;
}
Moving on in life in such a way that doesn't include HF. HF allowed me to get into the security field and peaked my interest: I appreciate everyone's time, effort, and encouragement. If for some reason you have a means to message me outside HF, feel free to, but I won't be coming back.
1) You are using way more header files than necessary. Don't do that.
2) If you do use a lot of header files, especially 3rd party ones, don't use "using namespace std" because that can result in some pretty bad name mangling.
3) You're defining a function within a function. Either that, or you just forgot to close the function above.
4) This:
PHP Code

<?php 
inline void keep_window_open
() {
    
char ch; cin >> ch;
} 
is not good...

From what I can tell, std::cin.ignore() is probably what you can use.
SRPP Discord Server

I am a professional network/cloud security architect.
My Old Tutorials
(May 22, 2016 11:03 AM)Mario® Wrote:  I have updated the thread with a newer question

"expected a function header"

Pretty obvious what's wrong
(May 22, 2016 11:03 AM)Mario® Wrote:  I have updated the thread with a newer question

You don't declare a function. You just write a scope that never gets run... there's no entry point.
SRPP Discord Server

I am a professional network/cloud security architect.
My Old Tutorials
(May 22, 2016 12:55 PM)Mario® Wrote:  Well I just started last night so no, it isn't obvious. If it was I wouldn't have asked.

I assume it should be the main function so the header of the main function is missing
Should look like that:

Code
void main() {
    ...
(May 22, 2016 01:07 PM)Remix Wrote:  I assume it should be the main function so the header of the main function is missing
Should look like that:

Code
void main() {
    ...

void main()? 🤨 .. ?
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
Yea its supposed to be int main() {

Was that the only problem that you were having tho?
(May 22, 2016 01:29 PM)Mario® Wrote:  I did int main and it worked out fine

I think you missed my point. I was hinting at the fact that it should be 'int main()' instead of 'void main()' as he had suggested.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(May 22, 2016 01:21 PM)0xDEAD10CC Wrote:  void main()? 🤨 .. ?

My bad, I saw he returned nothing and didn't use my brain
Has to be int


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Robin2Feb 10, 2018 04:35 AM 0 116 Feb 10, 2018 04:35 AM
Last Post: Robin2
[C#] by HurdleMar 26, 2017 01:39 AM 26 810 Mar 26, 2017 01:39 AM
Last Post: Magna imperium
[C] by GoodiesSep 2, 2016 08:36 PM 2 219 Sep 2, 2016 08:36 PM
Last Post: Goodies