Well, I have to process a large part of the text, it is an analysis from the beginning of the linear end and I wonder What is the best way to do this: using char * or std :: string. While using the four * i, the pointer can change to the next position in the string.
// Edit later: Some places are malling for the text str [] = "Text to analyze"; Char * orig = str; // process str + = processed_chars; // fast enough // process then // later: free (original); But to use the string I might have to use std :: string :: erase - but it can make a copy, or byte or something else (I have a real implementation Do not know)
string str = "text to analyze"; // process str = str.erase (0, processed_chars); Or is there a way to change the hidden indicator of std :: string?
Edit: Sylvain Dfresen requested more code here:
class tag {public: tags (fodder pch) {* pch = strstr (* pch , "& Lt;"); If (PP == faucet) return; Char * orig = * pch + 1; * Pch = strstr (* pch, "& gt;"); If (PP == faucet) return; * PCH + = sizeof (four); // rear & gt; // Process Inner Tag Data if (* (* pch-2)! = '/') {// while not auto-shutting down (! (** (pch == '& lt;' & amp; (* pch + 1) == '/')) {// to close the tag Search = Children = New tag (PP); Sublings.push_back (* child); } * Pch = strstr (* pch, "& gt;"); If (PP == faucet) return; * PCH + = sizeof (four); // rear & gt; // Add tag if the fabric tag is matched}}} I use it for parsing a symbolic XML-like sign
char str [] = "& Lt; father & gt; & lt; child /> & lt; / fatherr & gt;"; Char * pch = str; Tag * root = new tag (and pp); This code is ugly in hell form, I'm just starting with low-level pointer arithmetic and stuff, so far the visual components are used, so much more Not difficult
With std :: string , you might Std :: string :: iterator . Your code will be: std :: string str = "text to analyze"; Std :: string :: iterator iter = str.begin (); // process iter + = processed_chars;
Comments
Post a Comment