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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:45:37+00:00 2026-05-20T15:45:37+00:00

I am a new learner to C++. I have a text file, its contents

  • 0

I am a new learner to C++.
I have a text file, its contents like following:

Systemname    localtesthost
SystemIp      X.X.X.X
Systemowner   root
...

Now I want to extract the value of “Systemname”, that is “localtesthost”.

And I can extract the line containing “Systemname localtesthost”, but I don’t know how to extract the String “Systemname”.

Below is my program need help:

const char* configInfoFile = "config_info";//the text file name
ifstream ifs(configInfoFile);
    string line;
    while(getline(ifs,line)) {
        if(line.length() > 0){
            int index = line.find("SystemName");
            if (index != -1)
            {

                                .
                                .

            }

        } 
}

Could any one show me how to extract the string "localtesthost"?

Many thanks!

  • 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-20T15:45:38+00:00Added an answer on May 20, 2026 at 3:45 pm

    Here is an approach:

    1. create a std::istringstream using the line you just read in.
    2. read from the stream two std::string objects, key and value
    3. if the key matches what you are looking for, value should contain what you require.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a new visual basic learner and I already have some difficulties in
I am a very new zend framework and phpunit test learner. I have a
I am new to API's like today new. I have learned how to simply
I am new to jQuery. I have learned functions like SlideUp and Down but
I have a large data file consisting of a single line of text. The
apologies, really new C# learner. my application will have these windows: a main display
New to xml. Looking for XPath to search a xml file with python ElementTree
New to silverlight. Traditionally if I were to design a wizard-like process where a
New to both Ruby and Rails but I'm book educated by now (which apparently
I have been playing around with Scala parser combinators for some time now, and

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.