Hi
If I do
return 0;
on windows it immediately terminates the current function but on Linux it seems to only affect at the function end? Well it continues unlike Windows. How to immediately exit the function also on Linux?
Many thanks
Hi
If I do
return 0;
on windows it immediately terminates the current function but on Linux it seems to only affect at the function end? Well it continues unlike Windows. How to immediately exit the function also on Linux?
Many thanks
Using "return" or "return X" (where X is some value, if the function has a return value) will exit the function in all standards-compliant C++ compilers. This will cause the destructors of objects in scope to execute. It's very likely you're misunderstanding the behavior you're seeing, as it's extremely unlikely this is some kind of Linux/Windows behavioral delta on its own.
Please post the code in question.
Niko Suni
So return 0; should exit my while loop? It does on Windows. I'm playing around with break and return false: now without success. So there must be something else wrong with my code?
Thanks
int inith(string, string){
while(getline(nfs, Mtmp)){
if (Mtmp == "my"){
...do stuff...
break;
//return 0; //works on Windows
}
So there must be something else wrong with my code?
int inith(string, string){
while(getline(nfs, Mtmp)){
if (Mtmp == "my"){
...do stuff...
break;
//return 0; //works on Windows
}