Is there any way a C/C++ program can crash before main()?
-
Hi, I have one question... Is there any way a C/C++ program can crash before main()? Regards, Mbatra
-
The question is unclear: are you asking about compilation order?
int x = ;
int main()
{
return 0;
}this will not compile, error is before main
there are no facts, only interpretations
-
Hi, My question was: Is there any way a C/C++ program can crash before main()? Like when u run your program, it crashes even before it starts to execute main.. Regards, Mbatra
-
Hi, I have one question... Is there any way a C/C++ program can crash before main()? Regards, Mbatra
The initialization of your static variables are performed before main() and their deinitialization is performed after main() returns or after the exit() call. If you put buggy code in there then you can easily crash before/after main().
-
Hi, I have one question... Is there any way a C/C++ program can crash before main()? Regards, Mbatra
-
Hi, I have one question... Is there any way a C/C++ program can crash before main()? Regards, Mbatra
Here is a cooked-up example:
#include
using namespace std;class Crash
{
public:
Crash()
{
int *a = new int[5];
for (int i = 0; i < 7; ++i)
{
a[i] = 25;
}
delete[] a;
}
};Crash crash;
void main()
{
cout << "If ever I come here ..." << endl;
}This program will crash even before entering main().
-
Hi, I have one question... Is there any way a C/C++ program can crash before main()? Regards, Mbatra