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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:38:38+00:00 2026-05-29T07:38:38+00:00

for my CS class.. cant use vectors! Ive searched everywhere for some information on

  • 0

for my CS class.. cant use vectors! Ive searched everywhere for some information on how to read in lines of string from a txt into a two-d or 3d array and i cant find ANyTHING. i need some help please.

reading in a text file that looks like this:

  • what is the capital of texas?
  • austin
  • kansas
  • harlingen
  • dupont
  • blankline
  • blankline
  • what is the capital of maine?
  • etc
  • etc

so its blocks: 1 question 4 answers, two empty lines, repeat.

my array to store 50 questions, each with 5 lines

string questions[50][5];

my function to read in txt file into array

void read_questions(string[], string[])
{
ifstream.fin;
fin.open("questions.txt")
while (!fin.eof{}}
fin.getline([i][j];
}

i know i am far off but if you can point me to some references i would appreciate. ive looked through many resources and googled many times but cant find any examples close to mine atall. i asked at another site but they keep telling me to use vectors but we cant we have to use a 2d or 3d array

  • 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-29T07:38:39+00:00Added an answer on May 29, 2026 at 7:38 am
    string questions[50][5];
    

    That line declares an array of an array of strings. That’s a good enough start.

    To read each line in, you’ll need:

    • A function that reads in a single string
    • A loop to read in five strings, and
    • A loop to read in fifty sets of five strings

    The nested loops are easy:

    for(int i = 0; i < 50; ++i)
      for(int j = 0; j < 5; ++j)
      {
        do some work here.
      }
    

    Picking an input function is pretty easy, too. You’ll want to use std::getline(std::istream&, std::string&).

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

Sidebar

Related Questions

So I can't use initializers in my class constructor because of using arrays, so
In the inherited class I use the base constructor, but I can't use the
R class on android has it's limitations. You can't use the resources dynamically for
Why can't I use the function ColPeekHeight() as an l-value? class View { public:
How to use oAuth with PHP ? I can't install oauth class with pecl
I am trying to find why the class cant be created as a static?
I cant call protected function in my base class. Why? It looks something like
When a class is customized, by using its outlet , you cant access its
I have a class that should hold a reference to some data, without owning
I have some VHDL code I'm writing for a class. However, the synthesis tool

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.