+ 5
Differentiate between a run time error and syntax error ?
2 Respuestas
+ 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
+ 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;
}