0
Isn't the line 1 and line 4 means the same that is in *ptr and hello both contain manash so why hello runs but *ptr doesn't?
#include <stdio.h> #include <string.h> int main(){ char hello[] = "manash"; char * ptr = &hello; printf("%s\n",hello); printf("%s\n",ptr); printf("%s\n",&hello); printf("%s\n",*ptr); return 0;}
4 Réponses
+ 2
#include <stdio.h>
#include <string.h>
int main(){
char hello[] = "manash";
char * ptr = hello; //no need of & since it is charecter array, already points to starting addrress
printf("%s\n",hello); //%s prints total array
printf("%s\n",ptr);
printf("%p\n",&hello); // &hello returns address of hello array..
printf("%c\n",*ptr); //*ptr points to the value of first charecter array , not total array. and ptr returns total array.
return 0;
}
//hope it helps...
+ 1
There *ptr returns a single first charecter so need %c ..
0
Okay I got your point so does that mean
Printf("%c\n,*ptr); gives output m
My coding c app give me error but it's okay if It atleast give me m as an output
0
Ooo the small details
You Gotcha me
Well thanks for the help!