Why is 49, 50, 51, 52 stored in the array when I declare testArray[] = {'1','2','3','4','5'}? (C programming)

后端 未结 5 1348
醉梦人生
醉梦人生 2021-01-16 01:11

Why is 49, 50, 51, 52 stored in the array when I declare testArray[] = {\'1\',\'2\',\'3\',\'4\',\'5\'}? How should i initialize a string array? Thanks

5条回答
  •  有刺的猬
    2021-01-16 01:38

    because 49, 50, 51 are the ASCII codes for 1,2,3... You're initializing an array of characters, not strings

提交回复
热议问题