Now that im looking at everything im not sure c_str() is causing the extra data I think it might of been me so I guess going up a step does c_str() allocate any memory or is it a pointer to the data?
In C++11, c_str() and data() are the same, and are just a pointer to the data (not a pointer to a copy of the data). Calling these functions is O(1). In C++03, however, c_str() may return a copy of the internal buffer (iirc, C++03 didn't require strings to be stored in a contiguous buffer like in C++11). For all practical purposes, chances are your compiler (if using C++03) does use a contiguous internal buffer and that c_str() just returns a pointer to it. Note that &data()[0] is not safe! There's no guarantee the internal string is null-character terminated (in C++03), plus (again, iirc) there's no guarantee that it points to a contiguous buffer. However, most implementations will use a contiguous array, so just using c_str() should be good enough and should never create a copy (unless you're working on an exotic system or with a weird compiler) (this is in C++03; C++11 is of course as I previously mentioned).