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

  • Home
  • SEARCH
  • 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 6615309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:26:46+00:00 2026-05-25T20:26:46+00:00

I’m learning C++, and I’m doing work with data loaded from external text files

  • 0

I’m learning C++, and I’m doing work with data loaded from external text files using cin.

I’m trying to recognize certain strings in large amounts of data that I need to skip through.

How would I write a function that skips through a certain number of characters in a file / on a line, either as I’m importing them from a file? Does such a thing already exist in iostream or similar?

Google has let me down so far.

  • 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-25T20:26:47+00:00Added an answer on May 25, 2026 at 8:26 pm

    On general skipping: seekg

    On the real issue:

    It seems like you would want to be matching patterns against a large body of (semi?) text. Since the pattern is long enough that you can gain from skipping input stretches, it really seems you are trying to invent optimized string search all over.

    It has been done:

    • http://en.wikipedia.org/wiki/Boyer_Moore_string_search_algorithm
    • http://volnitsky.com/project/str_search/index.html

    Implementations exist in the wild (I assume Boost String Algorithm should have it… but maybe it too general-purpose to have it. I’d have a look anyways)

    PS.: Boost Spirit

    This parser is currently reviewing an enhancement that implements the qi::seek[] directive:

    • https://github.com/jamboree/boost-jamboree-spirit/blob/master/libs/spirit/repository/example/qi/seek.cpp
    • http://boost.2283326.n4.nabble.com/Proposal-for-qi-seek-directive-td3830251.html

    This allows blazingly fast skipping inside a Spirit grammar. So if you have a case for a full parser (perhaps even scanner/parser), Spirit Qi could really be your match in performance.

    Be sure to:

    • avoid buffering input iterator adaptors if you can (depends on grammar)
    • imbue “C” locale if you can
    • operate on the input streambuf’s iterators as opposed to input streams iterators
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of posts stored in text files formatted in yaml/textile (from
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.