#include <stdio.h>
void main()
{
    char *s= "hello";
    char *p = s;
    printf("%c\t%c", p[0], s[1]);
}
output of this program is : h e
Can anyone please explain how this program is working? I'm relatively new to c..
#include <stdio.h>
void main()
{
    char *s= "hello";
    char *p = s;
    printf("%c\t%c", p[0], s[1]);
}
output of this program is : h e
Can anyone please explain how this program is working? I'm relatively new to c..
p[0]  is identical to *(p+0) , similarly goes for s[1] . [] always operates on a pointer and is same for arrays and pointers.
Note - There is no array declared in your program.
 
    
    Please note the following facts first( They are neutral to programming LANGUAGE )
Any pointer has/ takes memory equals to size of your systems data bus
even void* takes size equals size of your systems data bus
Now size of data bus is size of processors data fetching/manipulating capacity, you might heard 32 Bit processor, 64 Bit processor
Finally processors data fetching/manipulating capacity equals size of your int, that's why we use following code to calculate Architecture of CPU
#include<stdio.h>
int main(){
if(sizeof(int)==2) {
    printf("\n 16 Bit Architecture, may be using DOS & Turbo C++ IDE");
}else if(sizeof(int)==4)  {
    printf("\n 32 Bit Architecture");
}else {
    printf("\n 64 Bit Architecture");
}
return 0;
}
