You take a perfectly good null-terminated string, Copy it into a String, do a load of memory intensive fiddling with it, then turn it back into a null-terminated string, just to convert it to a number. Interesting technique.
You don't seem to be resetting started and ended after you have processed your data.