+ 5

Differentiate between a run time error and syntax error ?

21st Jan 2018, 12:38 PM
Yash Garg
Yash Garg - avatar
2 Réponses
+ 9
Simple explanation: syntax errors occur when the compilers finds errors in your syntax. (before the code even ran at all) runtime errors occur when your code is already running
21st Jan 2018, 1:02 PM
wout werkman
wout werkman - avatar
+ 3
This would cause a syntax error: #include <iostream using std; int main ( cout >> “Hello World’::std ) This would cause a runtime error: #include <iostream> using namespace std; int main() { int * p = new int; *p = 27; cout << *p; //now pointing to nothing delete p; //nullptr exception cout << *p; }
21st Jan 2018, 1:08 PM
Jacob Pembleton
Jacob Pembleton - avatar