Well the way you declare str and initialize it using double-quotes means that it is stored in read-only memory, and effectively is a constant that can not be manipulated. That is not the problem, however, it is when you attempt to assign the character array to num on line 9. What you will get is the ascii value of the character in the first position in the array, if you can even do that assignment.