Discussion :: Strings - Yes / No Questions (Q.No.3)
|James said: (Aug 14, 2015)|
|It would be 9 characters - 8 plus one for NULL.|
|Akshay Immanuel said: (Jul 2, 2016)|
|By dereferencing the pointer and the array, won't they be the same?
Like ch (pointer declaration of ch) == ch (array declaration of ch)?
|Ramandeep said: (May 25, 2017)|
|Yes, you are Right @James.|
|Arda said: (Jun 8, 2019)|
|So for both cases what is ch, ch, ch, ch and *ch?|
|Mohamed said: (Jun 13, 2020)|
|Yes, there is a difference, first statement apointer (ch) is a non-constant pointer to non-constant string because we can assign pointer to another string, sizeof(ch) depends on the compiler and operating system.
But in second statement array of string, the name of an array is a constant pointer, we cannot assign the string in array to another string,sizeof(ch)in this statement is 8.
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.