Troubleshooting Compilation Errors: Why Won't My Program Compile?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
8 replies · 3K views
mkbh_10
Messages
217
Reaction score
0
Tell me why am i not able to compile this program, the terminal lists various errors

http://tinypic.com/r/1zxtm5h/7
 
Physics news on Phys.org
Two tips:

1. It's a lot faster for other people here if you paste your code directly into your posting instead of making us wait for a large picture to download. To keep the code formatted properly, enclose it in [ CODE ] and [ /CODE ] tags (remove the spaces that I added between the brackets).

2. It helps a lot if you tell us what compiler error messages you got, and what line they refer to.
 
I am new to programming , i will do wat u said ...
 
Worked fine for me.
What did you type to compile?

Looks like you are in Ubuntu, so try:
g++ sinx3.cpp -o runMe
 
I may be off here, but it appears that those first three lines are supposed to be comments but aren't being treated as such. If you notice the words 'buffer' 'is' and 'for' are all syntax highlighted. Also the text between the single quotes in don't and file's is highlighted as if it were a string constant.

I recommend changing those double semicolons to double slashes like the rest of the comments.
 
Yeah it seems you have written it in the Emacs *scratch* buffer and then saved it to file, remove the first 3 lines. Then try to compile with the command already written here.
 
i don't know if this will help your problem at all but I am also new to c++ and i have just gotten in the habit of including: "#include <cstdlib>" ; and "using namespace std". in all of my programs
 
@ Bad
He's writing in C, not C++
But aside from that, namespace std - in the future you should consider only import those that actually needed.
But at the moment it's okay.