In C99, a string is usually initialized using the char* data type, since there is no primitive data type of the type. This effectively creates an array of characters, storing the address of the char variable in the variable:
FILE* out = fopen("out.txt", "w"); char* s = argv[1]; fwrite(s, 12, 1, out); fclose(out);
How does the compiler know that char* s is a string, not just the singular address of char ? If I use int* , it will only allow one int , not an array of them. Why is the difference?
My main focus is understanding how pointers, links, and dereferences work, but the whole char* keeps fiddling with my head.
source share