Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4065586
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:00:07+00:00 2026-05-20T16:00:07+00:00

well i have to process a large chunk of text, analysing it linear from

  • 0

well i have to process a large chunk of text, analysing it linear from begin to end. And i wonder what is the better approach for this: using char* or std::string.
while using char* i can alter the pointer to a position further in the string eg.

//EDIT later: mallocing some space for text
char str[] = "text to analyse";
char * orig = str;
//process
str += processed_chars; //quite fast
//process again
// later: free(orig);

but using string i might have to use std::string::erase – but it create a copy, or move bytes or something (i don’t know the actual implementation)

string str = "text to analyse";
//process
str = str.erase(0,processed_chars);

or is there a way to alter the std::string’s hidden pointer?

EDIT: as Sylvain Defresne requested here more code:

class tag {
public:
    tag(char ** pch) {
        *pch = strstr(*pch,"<");
        if(pch == NULL) return;

        char *orig = *pch+1;
        *pch = strstr(*pch,">");
        if(pch == NULL) return;
        *pch+=sizeof(char); //moving behind the >

        //process inner tag data

        if(*(*pch-2)!='/'){// not selfclose
            while (!(**pch == '<' && *(*pch+1) == '/')){ //sarch for closing tag
                tag* kid = new tag(pch);
                sublings.push_back(*kid);
            }

            *pch = strstr(*pch,">");
            if(pch == NULL) return;
            *pch+=sizeof(char); //moving behind the >

            //add check if the clothing tag is matching

        }
    }
}

i use it for recursive xml-like notation parsing

char str[] ="<father><kid /></fatherr>";
char * pch = str;
tag *root = new tag(&pch);

this code is ugly as hell, i am just starting with low-level pointer arithmetic and stuff, used visual components till now so don’t judge too hard

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:00:08+00:00Added an answer on May 20, 2026 at 4:00 pm

    With std::string, you would probably use std::string::iterator. Your code would be:

    std::string str = "text to analyse";
    std::string::iterator iter = str.begin();
    
    // process
    iter += processed_chars; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well I have this code in my Managed C++/Cli in Visual Studio 2008, I
I have a process that sends to printer a large amount of .doc files
How do I append to large files efficiently. I have a process that has
I have server that needs to process and dump from an SQL database queries
I'm in the process of porting a large C++ application from Linux (gcc) to
I have a large text file of records, each delimited by a newline. Each
Well i have a gridview where i have defined the columns on my own
Well i have a transparent div or the background is set to transparent :)
well i have most probably an extremly stupid problem but could not figure it
Well i have a control thats placed in a usercontrol and it exposes a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.