I'm looking to retrieve bits of information from a char string.
Basically I get a string with delimiters in a few spots, then I have to get the substrings between each of those delimiters.
For instance, I have a char string that gets an IP address such as "18.104.22.168". And what I have to do is extract the "150", "40", "230", and "8" in individual elements of a  element array of type int.
And I want to get those into an array called octet. So in the end I want-Code:char ip_address = ""; cout << "Enter an IP: "; cin >> ip_address;
octet = 150
octet = 40
octet = 230
octet = 8
I was thinking of using the strtok() function, but wasn't sure exactly how to get it to work. Or perhaps the strchr() function in some way?
Maybe somehow I could get the position of the first ".", read the stuff before that into octet, then from that position find the position of the next "." and read in the stuff between those two positions into octet, and so on until I read the last octet where I read from the position of the last "." to the null terminator. Just not sure how the code would look for that.