This was a question from an exam :
does this code always works ?
the answer is :
the if statement checks if the virtual address of 'str' is pointed to the beginning of a page, only then the strcpy should be executed and it will work because the whole page is accessible by this process.
Can anyone please explain me this ambiguous answer ? thank you very much
int main () {
char *str ;
str = (char*) malloc (sizeof(char)*4);
if ( ((int)str) & 0x00000FFF) != 0) return 0;
strcpy ( str ,"1234567890") ;
printf ("str=%s", str ) ;
return 0;
}