char *str = "hello";
char str[] = "hello";
can u differentiate these?
char *str = "hello";
char str[] = "hello";
can u differentiate these?
Sure I can:
Output:Code:#include <stdio.h> int main(void) { char *str = "hello"; char str2[] = "hello"; printf("%d - %d\n", sizeof(str), sizeof(str2)); return 0; }
Code:4 - 6
If you understand what you're doing, you're not learning anything.
That's a difference, not a differentiation. To differentiate you'd have to do d(str1)/dx * dx/d(str2).
To the op. One's a pointer which holds the address of a memory location holding "hello\0" - this memory location is likely read-only if you're using a modern compiler. The other's a read/write array holding "hello\0". See C Strings (Arrays vs. Pointers)
If you understand what you're doing, you're not learning anything.