0

So I have this problem, where I have a string like this with points:

"TaskA:55 TaskB:23....." etc. Is there a function with witch I can get the points from this? I'm familiar with strstr, but that returns me the pointer to the first letter of the word if found if I'm correct, so how do I get the number after? Thanks a lot in advance for your help!

Rokin
  • 1,977
  • 2
  • 20
  • 32

3 Answers3

0

You can split the string based on : and then take the second part. The second part is the numerical value which you require.

Himanshu Singh
  • 2,117
  • 1
  • 5
  • 15
0

You should look at strchr(), and try to find the colon.

Phantom
  • 833
  • 1
  • 9
  • 26
0

Try using strtok to split the string. strtok() will modify the string passed into it so if the original string is required elsewhere, make a copy of it and pass the copy to strtok().

Devanshi Mishra
  • 487
  • 5
  • 15