Behaviour of char pointers in C -
Behaviour of char pointers in C -
i reading string file in next format: n // length of string abcdef // string of length n
like that:
char necklace[400]; fin = fopen("file.in", "r"); fscanf(fin, "%d %s", &n, necklace); char* left = &necklace[0]; char* right = &necklace[n-1]; however, when declare char* before using them, it gives me compilation errors:
char necklace[400]; char* left, right; // causes problem fin = fopen("file.in", "r"); fscanf(fin, "%d %s", &n, necklace); left = &necklace[0]; right = &necklace[n-1]; could please explain me behaviour?
the right way :
char *left,*right; when do
char *left,right; then
char *left; char right; /*this not need need *right got right*/ so see compilation errors
c pointers char declaration
Comments
Post a Comment