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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:24:43+00:00 2026-06-01T17:24:43+00:00

I am writing a small program that will read a plain ASCII text file

  • 0

I am writing a small program that will read a plain ASCII text file containing 3 lines in 5 records, as follows:

f_name l_name
ID#
int int int int

I successfully put the first 2 lines in the 1D arrays where they belong, but I am having trouble putting the series of ints in the 2D array. My closest approach to the solution has been using the line:

studentScores[row][col] = atoi(input.c_str());

However, atoi parses only the first number, then throws away the rest of the line. I need to put each number in the string in a separate element of the array. I tried using stringstream, but I cannot get it to work correctly; apparently, the function I want to use is included in a different version of stringstream than I am using.

What could I use to parse this 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-01T17:24:45+00:00Added an answer on June 1, 2026 at 5:24 pm
    #include <string>
    #include <sstream>
    
    // ...
    
    int ints[4];
    std::string input;
    std::getline(stream, input);
    std::istringstream(input) >> ints[0] >> ints[1] >> ints[2] >> ints[3];
    

    (Error handling omitted for brevity.)

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

Sidebar

Related Questions

I'm writing a small program in C that will read input from the console.
I'm creating a small program that saves a int value into a text file,
I am writing a program that will read and write characters, converting lowercase characters
I'm writing a small/beta testing program that will be put to use in my
I am writing a small program that gets activated when sms is received.We need
I'm pretty new to C# and Visual Studio. I'm writing a small program that
I'm writing a small JavaScript program that makes web calls to pull up weather
I am writing a small program in Visual Studio 11 (beta) that a console
Today I am writing a small program in Haskell. I found that in ghci's
I am writing a small computation program with lot of read operations on blob

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.