Issue with conversion of string to ip address

Dear all,
I am working on a module where I am using Simcom A7672S GSM module.
When I am running command to get the ip address of the GSM module, I am getting correct ip address inform of string.
But when I am trying to convert that string to IP address I am getting not proper output. Not getting last octate.
Here is the code which I have written.

if (ipstat) {
        Serial.println(str);
        i = str.indexOf(",");
        str = str.substring(i + 1);
        Serial.println(str);
        ip.fromString(str);
      }

Here what is I am getting in output.

19:51:05.652 -> +CGPADDR: 1,10.3.85.36
19:51:05.652 -> 10.3.85.36
19:51:05.652 -> OK
19:51:05.652 -> OK
19:51:05.652 -> 10.3.85.0

When I am printing ip using

Serial.println(ip);

I am getting 10.3.85.0
Where in output I should get 10.3.85.36

let me know if there is any issue with code.

Did you manage to successfully do this with IDE 1.x ? But now it doesn't work in IDE 2.x ?

You posted your question in the forum section for IDE 2.x questions.

Let me know if you want to move it somewhere else.

Thank you for your quick response.
It's my mistake that I posted it in IDE 2.X questions, I am sorry for that.
I got the solution.
String was new line terminated, where it should be null character terminated.
I have changed the code and now it's working.
I posted the question because I was working on this part for more than 2 hours, tried all possible ways to solve it.

I am adding corrected code.

        Serial.println(str);
        i = str.length();
        str[i-1]= '\0';
        i = str.indexOf(",");
        str = str.substring(i + 1);
        Serial.println(str);
        ip.fromString(str);

That doesn't sound right. You don't need to null-terminate String type, or use any other terminator. String type maintains a separate length attribute so that no termination is required.

I have decided I will move your topic to the Programming section, since you no longer care.