Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
void main()
{
printf(3+"Helloworld\n");
}


Im getting output as loworld. First three characters are removed. How does printf working here?
Posted

1 solution

printf expects a pointer to a string, the compiler is storing the string "Helloworld\n" in your STATIC portion of your exe, and referring to that pointer - you're adding 3 to it, so printf will start at the pointer+offset3 .. hence 'loworld\n'
 
Share this answer
 
v2
Comments
CPallini 30-Jun-15 3:23am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900