int *i; *i=123;
He can, but there he can do something again - he shows that C Standard causes " undefined behavior ".
Yes. There is no allocated memory to accommodate the value 123.
123
As for initialization, a type variable is intnot guaranteed 0, it is int*not guaranteed to be a secure address.
int
0
int*
It can also potentially lead to data corruption.
32- :
. Release. , , , 100%. 100% Debug. .
, , , . , ( - ), -. "-"? , .
. :
int target = 0; int *i = ⌖ printf("target=%d\n", target); *i=123; printf("target=%d\n", target);
, .
int *i;This allocates memory for the pointer, but this variable is not initialized, so the value is completely arbitrary. Then you play it out so that you have a random address and write to this place in memory, but 1) you don’t know where the place is 2) this place is probably not yours. You can fix it with initialization likeint * i = ( int* ) malloc( sizeof(int) )
int *i;
int * i = ( int* ) malloc( sizeof(int) )
Source: https://habr.com/ru/post/1727032/More articles:How are relationships inherited in a UML class diagram? - inheritanceSearch operator overview '=> - asp.net-mvcHow to get datetime from python date object? - pythonКак я могу отлаживать код, который вызывается с помощью java-отражения? - javaA naming convention that works with IntelliSense - c #Expect - get a variable from the screen area based on row and column - scriptingJ2ME Application Development Guide - netbeansFor_each overload for specific types of iterators - c ++Regular expression to search for string in Expect buffer - stringWhat is the best way to organize unobtrusive JavaScript across multiple pages? - javascriptAll Articles