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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:40:13+00:00 2026-05-13T21:40:13+00:00

I need to create a function that uses a loop. This function will open

  • 0

I need to create a function that uses a loop. This function will open a text file and then must be able to skip a variable number of leading random integers. The program must be able to handle any number of leading random integers.

Example if the opened file reads this on its first line:

100 120 92 82 38 49 102

and the SKIP_NUMBER variable is assigned 3 the number the function would grab is 82.

The function must continue to grab the integers every SKIP_NUMBER until it reaches the end of the file. These integers taken from the txt file are then placed into another text file.

Please help I’m really lost on how to create this loop! 😀

Here is my function so far…

//Function skips variables and returns needed integer
int skipVariable (int SKIP_NUMBER)
{

return 0; //temporary return
}

These are my program variables:

// initialize function/variables

ifstream fin;
string IN_FILE_NAME, OUT_FILE_NAME;
int SKIP_NUMBER;
  • 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-13T21:40:13+00:00Added an answer on May 13, 2026 at 9:40 pm

    If I were you, I would approach this problem like this:

    1. create ifstream object m_strm
    2. open the file
    3. whie (m_strm.good())
        (a.) use ifstream's getline() to read a line from the file
        (b.) use strtok() function to tokenize the string (for whitespaces)
        (c.) maintain a counter when you keep getting tokens
        (d.) Now you can skip whenever you like.
    4. Done with file, so close the stream!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 336k
  • Answers 336k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Something like this has worked for me (assuming no shadow):… May 14, 2026 at 3:51 am
  • Editorial Team
    Editorial Team added an answer You do not say if you run the php from… May 14, 2026 at 3:51 am
  • Editorial Team
    Editorial Team added an answer Remember that we intentionally don't provide this because the library… May 14, 2026 at 3:51 am

Related Questions

The goal: To create a .NET dll i can reference from inside SQL Server
I am trying to create a generic list class for use with tiOPF (an
I have created a class library in VB .NET. Some code in the library
In C++, is it possible to have a base plus derived class implement a
Of course, I know the best answer is don't write your own cross-platform code,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.