// Pantea Aria // pointers and strings #include int main() { char str[] = "Hello World"; // make a pointer *s to this string char *s = str; // char *s = &str[0]; // print out each character printf("str is %s\n", str); printf ("str char by char:"); int i = 0; while(s[i]) { putchar(s[i]); //putchar(s[i]); i++; } printf("\n"); printf("using the pointer %s", s); printf("derefrencing char by char:"); i = 0; while (*(s + i)) { putchar(*(s + i)); // putchar(*s[i]); i++; } printf("\n"); // do not change str // print out the address of the string printf("the address of str is %p\n", str); printf("The address of str is %p\n", s); // print out the address of where 'W' is stored printf ("Address of W is %p and the value is %c\n", &str[6], str[6]); // can you move s to point to 'W' and not 'H'? how? s = s + 6; printf ("s is now %p\n", s); // Can I move str to point to 'W' and not 'H'??? NO pls don't return 0; }