Question:
How to get rid of syntax errors in programming?
mikeloveseagles
2013-03-08 08:17:12 UTC
Can be as ridiculous (or serious) suggestions as possible
Seven answers:
Darnental
2013-03-08 08:24:55 UTC
Write better code.



Seriously. Syntax Errors happen when you've made a colossal mistake in your code. That often means you've misspelled something, or put a semicolon, period, parenthesis or bracket in the wrong place. Pay attention to the error so you can know what needs fixing.



Use an IDE. If you're coding in Java, use Eclipse (which is free) as it checks syntax on the fly and underlines errors in red so that you know what the issue is and you can fix it. There is also Eclipse for other languages, but those can be difficult to set up. If you're coding in C or C++ or any Microsoft language, use Visual Studio. There is a free Express edition of Visual Studio that you can write your code on then use the free MINGW compiler to compile it. Or you can use Bloodshed-Dev C++ or CodeBlocks but they are not nearly as good.



If you don't have an IDE or are programming in a language that you can't find one for (like Python or PhP) pay close attention to the line number in the first Syntax Error. It's probably either there, or a within a few lines above it.
Almighty Wizard
2013-03-08 08:27:13 UTC
Using an IDE complete with autocomplete and intellisense is a good start, but this won't stop all syntax errors.



Depending on the language you are using, some compilers offer some syntax and code clean up options. JavaScript has a few 3rd Party tools on the internet that can compile JS code, check for syntax errors, and attempt to correct them. (Google Closure Linter and Compiler comes to mind)



Other than that, I think the best suggestion is, "Just don't. Stop it. Don't code a syntax error."
anonymous
2013-03-08 08:24:23 UTC
Well syntax errors mean you have an error in your code.

If it tells you what line number, go to that line and see if it is calling a wrong variable, or perhaps the line above it has caused a problem.
DUKE UnDiSpUtEd
2013-03-08 08:24:20 UTC
First make a format having all proper headers...#include...etc in a text document and save it on desktop,now each time u make a program jus copy paste the correct format and all u have to do is to fill the body.,u can also test run the program and it will highlight the errors.
anonymous
2017-02-20 17:51:00 UTC
tutor us your change code. change (expression) { case constant1: [insert statements]; smash; case constant2: [insert statements]; smash; default: [insert default statements] } occasion change (x) { case a million: cout << "x is a million"; smash; case 2: cout << "x is two"; smash; default: cout << "fee of x unknown"; } The final functionality is especially easy. I won't circulate into element because of the fact lots of the relaxing is figuring all a thank you to make the set of rules. only circulate word by making use of word, counting the characters between whitespace and storing the word and the selection. in case you do no longer hit upon a larger one after one you in basic terms checked, do no longer shop the hot information.
?
2013-03-08 08:19:15 UTC
Use Autocomplete and Intellisense-type features.
?
2013-03-08 08:23:42 UTC
By learning how to program?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...