0

In c what is meant by char *s? I know char s is declaring s variable of character but what * means?

C language question

22nd Jul 2018, 11:10 AM
Saurabh Jankat
Saurabh Jankat - avatar
3 Réponses
+ 1
Hi, C is a bit special, if you declare this: char x; It will only accept single chars like x = 'a'; x = 'z'; If you want to save a entire string you should use char x[length] To use it as an array to store multiple chars, but take care, save the last index to put this char: '/0', that means the end of the string The advantage of using char* is that don't need to set the length and then you don't have to be worried about having space to put the '/0' last char I'm not specialist in C, so correct me if I'm wrong! Hope it helps you
22nd Jul 2018, 11:33 AM
Guillem Padilla
Guillem Padilla - avatar
+ 1
* is a pointer, that means you are creating a pointer that references a location in memory, I'm sure about that
22nd Jul 2018, 11:54 AM
Guillem Padilla
Guillem Padilla - avatar
0
But r u 100%sure of char* i don't know that
22nd Jul 2018, 11:48 AM
Saurabh Jankat
Saurabh Jankat - avatar