String literals

If you were dealing with C strings a lot, malloc-ing the memory and stuffing the characters in one by one would be a real pain. Instead, you can create a pointer to a string of characters (terminated with the zero character) by putting the string in quotes. Change your code to use a string literal:

i​n​t​ ​m​a​i​n​ ​(​i​n​t​ ​a​r​g​c​,​ ​c​o​n​s​t​ ​c​h​a​r​ ​*​ ​a​r​g​v​[​]​)​
{​
 ​ ​ ​ ​c​h​a​r​ ​x​ ​=​ ​'​!​'​;​ ​/​/​ ​T​h​e​ ​c​h​a​r​a​c​t​e​r​ ​'​!​'​

 ​ ​ ​ ​w​h​i​l​e​ ​(​x​ ​<​=​ ​'​~​'​)​ ​{​ ​/​/​ ​T​h​e​ ​c​h​a​r​a​c​t​e​r​ ​'​~​'​
 ​ ​ ​ ​ ​ ​ ​ ​p​r​i​n​t​f​(​"​%​x​ ​i​s​ ​%​c​\​n​"​,​ ​x​,​ ​x​)​;​
 ​ ​ ​ ​ ​ ​ ​ ​x​+​+​;​
 ​ ​ ​ ​}​

 ​ ​ ​ ​c​h​a​r​ ​*​s​t​a​r​t​ ​=​ ​"​L​o​v​e​"​;​ ​ ​ ​ ​p​r​i​n​t​f​(​"​%​s​ ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.