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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:24:40+00:00 2026-06-14T16:24:40+00:00

I have a file which holds protein coordinates as well as other information preceding

  • 0

I have a file which holds protein coordinates as well as other information preceding it. My aim is to look for a certain line called “$PARAMETERS” and then copy from there every line succeeding it till the end of the file.

How can I get that done? This is the small code I wrote part of the entire program (that someone else wrote years ago, and I took over to upgrade his code for my research):

ifstream InFile;
InFile.open (DC_InFile.c_str(), ios::in);

while ( not InFile.eof() )
{
    Line = NextLine (&InFile);

    if (Line.find ("#") == 0) continue;   // skip lines starting with # (comments)
    if (Line.length()   == 0) continue;   // skip empty lines
    size_t pos = Line.find("$PARAMETERS");
    Line.copy(Line.begin("$PARAMETERS")+pos, Line.end("$END"));
    &Line.copy >> x_1 >> y_2 >> z_3;

}

Bearing in mind that I defined Line as string

  • 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-14T16:24:41+00:00Added an answer on June 14, 2026 at 4:24 pm

    I guess you need to read data between $PARAMETERS and $END, not from $PARAMETERS until end of file. If so, you can use the following code:

    string str;
    while (getline(InFile, str))
    {
        if (str.find("#") == 0)
            continue;
        if (str.length() == 0)
            continue;
        if (str.find("$PARAMETERS") == 0)
        {
            double x_1, y_2, z_3; // you want to read numbers, i guess
            while (getline(InFile, str))
            {
                if (str.find("$END") == 0)
                    break;
                stringstream stream(str);
                if (stream >> x_1 >> y_2 >> z_3)
                {
                    // Do whatever you want with x_1, y_2 and z_3
                }
            }
        }
    }
    

    This will handle multiple sections of data; not sure if you really want this behavior.

    For example:

    # comment
    $PARAMETERS
    1 2 3
    4 5 6
    $END
    #unrelated data
    100 200 300
    $PARAMETERS
    7 8 9
    10 11 12
    $END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a config.php file for one of my site which holds information needed
I have a file which I'm trying to extract information from, the file has
i have a file which contains a lot of update query and some other
I have a selectedArray defined as a property in my file that holds which
I have a vector of strings: std::vector<std::string> fName which holds a list of file
I have an array which holds a record from a CSV file. Can I
I have a file, which holds phone number data, and also some useless stuff.
In asp.net mvc3, I currently have a single file ViewModels.cs which holds all of
var PageLoad = true; I have a file named properties.js which holds this value
I have a XML file which holds configuration data for data sources, and the

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.