- 3
String strchr() Function
https://code.sololearn.com/cA19A16A191A 8.8 Write the strchr() function. the code works fine in codeblocks. Idk why it is causing an error here. Anyway, my question is , in line 11 what is the use of p && *p?
6 odpowiedzi
+ 4
It's giving you error because you have two functions of same name and parameters in your program.
You are including cstring header file which contains strchr function already and then you are declaring your own function.
Just rename your strchr function or just don't include cstring header file.
You can't have two functions of same name in one program.
https://code.sololearn.com/cmuO8BTYzkwD/?ref=app
+ 2
If you are running a loop then you need to stop it at some point. Right!
p && *p is used to check if pointer points to valid memory area.
It is also checking Null Character '\0'.
You are using it in for loops as condition. When your pointer p will be at Null Character then it will return 0 and your loop will break.
0
Ok @shail Thanks
0
hi