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 8941575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:20:14+00:00 2026-06-15T11:20:14+00:00

I have an HTML data in a char* and I would like to get

  • 0

I have an HTML data in a char* and I would like to get it line by line, do some replacements and then add them all up together into a single string. This is the code that I use

std::string to, finalData;
finalData = ""; 
char* char_array = strtok(data, "\n");
while(char_array){
    finalData += std::string(char_array);
    char_array = strtok(NULL, "\n");
}  

The problem is the data that I get at the end of this (finalData) has a lot of ^M characters and I am unable to search for it as it has a special character. Is there any way to completely eliminate the character?
I am guessing that it has something to do with conversion from c array to c++ string and to do with \n as tab is represented by ^I and cntrl is represented as ^

  • 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-06-15T11:20:16+00:00Added an answer on June 15, 2026 at 11:20 am

    It seems that you are on a Windows system, or that the data originated on a Windows system. On a Windows system, newline is actually two characters: "\r\n". What you are seeing as ^M is the carriage-return character ('\r') of that newline sequence.

    One way to remove those extra characters, would be to use std::string::find and std::string::erase in a loop.

    Another way would be to manually copy, character by character, to a new std::string, except if the character is '\r'.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some non well-formed xml (HTML) data in JAVA, I used JAXP Dom,
If I have HTML content in a variable like so: var data = <div
i have a html page in which i enter data which then submits and
I have an HTML (App) file that reads another HTML (data) file via jQuery.ajax()
If I have the xml/html data to post we need to encode the data
I have around 5 GB of html data which I want to process to
I have very very big html page/data. I need to fetch data under h1
I have a html form with the data by this post method 'form id='form1'
im trying to import html table data to an excel file and have succeeded
I have a question about grabbing a certain value from the html response data

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.