void skip(char *msg)
{
puts(msg+6);
}
char *message="Don't call me";
skip(message);
My doubt is why we don't use
puts(*(msg+6)) to display text from 7th character onward;
according to me (msg+6) refers to memory and *(msg+6) content
*msg is essentially a reference to a single char, not to the string of char's. due to this char * and char[] are essentially the same thing and you don't need to dereference character pointer in C because compiler automatically print fully string from given base address upto '\0' not get. you can also refer this for more info .
#include <stdio.h>
void skip(char *msg) {
puts(msg + 6);
}
int main() {
char *message = "Don't call me";
skip(message);
}
putswants the 'memory' (or rather, a pointer).*(msg + 6)is but a single character, not a string.int printf(const char *restrict format, ...);printfexpects a (character-)pointer for every%sin the format. I don't understand what you're not understanding...