Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

c++ error


  • Please log in to reply
3 replies to this topic

#1 Reddoug

Reddoug

  • Members
  • 115 posts
  • OFFLINE
  •  
  • Local time:02:01 PM

Posted 16 June 2018 - 02:12 PM

Hi All

 

I am getting an error when trying to run a c++ Hello World program. I have checked and rechecked and cannot figure out why I am getting an error. Compiles with no errors, only errors when I try and run it.

I am trying to run this on Ubuntu 16.04 LTS.

 

Hoping different eyes can see what I am missing.

 

#include <iostream>

int main(int argc, char *argv [])
{
    std::cout << "Hello World!" << std::endl;
    
    return 0;
}

 

Error

./helloworld.cpp: 3: ./helloworld.cpp: Syntax error: "(" unexpected

 

Thank you

Doug

 

 

 

 



BC AdBot (Login to Remove)

 


#2 axe0

axe0

  • Malware Study Hall Junior
  • 289 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Netherlands
  • Local time:09:01 PM

Posted 16 June 2018 - 06:55 PM

Hi Doug,

How are you trying to run it?
Kind regards,
Axe0

#3 Reddoug

Reddoug
  • Topic Starter

  • Members
  • 115 posts
  • OFFLINE
  •  
  • Local time:02:01 PM

Posted 17 June 2018 - 06:10 PM

Thank you for your reply.

 

I used ./helloworld.cpp to try and run it. Permissions were changed to 755. Did try the exact same script in Windows using Code Blocks, no problems.

 

I used   gcc helloworld.cpp -o helloworldcpp    to compile in Ubuntu. Don't see why it works in Code Blocks but not Ubuntu.

 

Thanks again

Doug



#4 RecursiveNerd

RecursiveNerd

  • Malware Study Hall Junior
  • 199 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Louisville, KY
  • Local time:03:01 PM

Posted 02 July 2018 - 01:09 PM

Have you verified that the compiler on Windows is using the same compiler that Ubuntu is using. I believe Ubuntu uses GNU GCC whereas Windows uses MinGW from what I can tell.

 

Also, you can't run a .cpp file from Unbuntu command line. You would want to run using ./helloworldcpp and not ./helloworld.cpp.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users