Question du test C++

Quel est le résultat du code suivant ? #include <iostream> #include <string> using namespace std; int main() { int a = 10; int b = 20; int c = a + b; cout << c; return 0; }

Difficile

What is the output of the following code:

int main(int argc, char *argv[])
{
        	
        	try
        	{
     	           	char* ptr;
     	  
     	           	strcpy(ptr, "C++ world");
     	  
     	           	ptr++;
     	  
     	           	std::cout<<ptr<<std::endl;
        	}
        	catch(...)
        	{
  	              	std::cout<<"caught some unhandled exception"<<std::endl;
        	}
        	return 0;
}

Auteur: Abha AgrawaStatut : PubliéeQuestion passée 443 fois
Modifier
0
Évaluations de la communauté
developer avatar
Sandra
29/05/2024
This is deprecated and probably won't even compile (str is uninitialized and strcpy_s should be used rather than strcpy)