+ 3

Substring in C?

Is there any function in C language to print substring like in java there is substring(index1, index2)?? If yes then please show me example of code using substring

15th Mar 2020, 9:34 AM
Shaikh Nabeel
Shaikh Nabeel - avatar
3 ответов
+ 3
There is no built-in substring function in string header. You can make your own version by using `strncpy`. But mind you if negative index is allowed, careful calculation is needed to copy the desired characters from and to the correct index.
15th Mar 2020, 9:59 AM
Ipang
+ 3
Try the strstr and there lot more you can check out the documentation
15th Mar 2020, 9:45 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
Remember that you can make your own methods. Try to sort it out. Check C method tutorials for char arrays in Google.
15th Mar 2020, 9:51 AM
Fernando Pozzetti
Fernando Pozzetti - avatar