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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:06:22+00:00 2026-05-21T21:06:22+00:00

i am trying to pass an array between two functions. The _data function is

  • 0

i am trying to pass an array between two functions. The _data function is my array. It takes 3 parameters; the array itself, the size of the array and the file name of the array. So this function should get each element from the input file(.txt) and put it into the array, which it seems to do ok.

void _data(string dataArray[], int sizeOfArray, ifstream &fin)
{
    const int CharBuffer=20;
    char linedata[CharBuffer];
    ifstream& getline (char* s, streamsize n );

    for(int x = 0; x < sizeOfArray; x++)
    {
        fin.getline(linedata, CharBuffer);
        dataArray[x]=linedata;
        cout << dataArray[x] << endl;
    }
}

ifstream& operator>>(ifstream &fin, ArrayIntStorage &AIS)
{
    string acwData[10000];
    _data(acwData, 10000, fin);
    return fin;
}

but in the next part I need to output the values from my array to a text file which I must do in a separate function.

So my question is, how can I access the data stored in the acwData array above in the function below?(or any other function)

ofstream& operator<<(ofstream& fout, ArrayIntStorage& AIS)
{
    return fout;
}

do i need to initialize my array function differently to include a return type?

  • 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-21T21:06:23+00:00Added an answer on May 21, 2026 at 9:06 pm

    Several things wrong with this code:

     void _data(string dataArray[], int sizeOfArray, ifstream &fin)
    

    Names that begin with an underscore are reserved for the C++ implementation in most circumstances – don’t use them in your own code unless you have read the C++ Standard fairly closely, which I suspect you have not.

     ifstream& getline (char* s, streamsize n );
    

    Don’t declare standard library functions yourself. This function is declared in <iostream> so you should #include that header.

    The use of an array is suspect. As you are obviously using C++ and the standard library, why not use a vector<string> which you should pass into your function as a reference.

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

Sidebar

Related Questions

I'm trying to pass an instance of a class between two separate classes, like
I am trying to pass a member function within a class to a function
I'm currently trying to pass a mono threaded program to multithread. This software do
I'm trying to pass messages between 2 threads using a queue, but I haven't
I'm trying to pass some representation of an image back and forth between Silverlight
I'm trying to pass in a Base64 string into a C#.Net web application via
I'm trying to pass one method to another in elisp, and then have that
I am trying to pass some Subsonic collections to a client via a web
I'm trying to pass a complex object (that can be serialized, if that helps)
I'm trying to pass a null value for the first parameter in the code

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.