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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:47:34+00:00 2026-06-16T07:47:34+00:00

could I ask for advice? Please, could someone give an example of code, which

  • 0

could I ask for advice? Please, could someone give an example of code, which deletes spaces from lines of the first text file and saves “new text without spaces” into the second file. I understand how it be probably working, but I can not write it, because i am beginner in programing. Thanks for any advice.
My codes:

        //read csv file
         void readCSV(istream &input, vector< vector<string> > &output)
            {
                string csvLine;

                while(getline(input, csvLine) )
                {
                    istringstream csvStream(csvLine);
                    vector<string> csvColumn;
                    string csvElement;

                    while(getline(csvStream, csvElement) )
                    {
                        csvColumn.push_back(csvElement);
                    }       
                    output.push_back(csvColumn);
                }
            }


        //save all from csv to txt 
        void saveToTxt()
        {

            fstream file("file.csv", ios::in);

            ofstream outfile;
           outfile.open("file.txt");

            typedef vector< vector<string> > csvVector;
            csvVector csvData;

            readCSV(file, csvData);


            for(csvVector::iterator i = csvData.begin(); i != csvData.end(); ++i)
            {
                for(vector<string>::iterator j = i->begin(); j != i->end(); ++j)
                {

                    outfile<<*j<<endl;

                }



//code for deleting spaces, what i found, but i can't implement to above codes, coz my programming skill are not big

                   string s;   
                          while (getline( cin, s ))
                            {
                            s.erase(
                              remove_if(
                                s.begin(),
                                s.end(),
                                ptr_fun <int, int> ( isspace )
                                ),
                              s.end()
                              );

                            cout<<s<<endl;
  • 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-16T07:47:36+00:00Added an answer on June 16, 2026 at 7:47 am

    I love solutions which won’t qualify as a result for a homework assignment. Below is how I would write code for the specification, partly because I genuinely think that this is how it is to be done and partly to give others a bit of interesting reading. It contains all the necessary hints to create a teacher-friendly solution, too:

    #include <algorithm>
    #include <cctype>
    #include <iterator>
    
    int main() {
        std::remove_copy_if(
            std::istreambuf_iterator<char>(std::ifstream("in.txt").rdbuf()),
            std::istreambuf_iterator<char>(),
            std::ostreambuf_iterator<char>(std::ofstream("out.txt").rdbuf()),
            [](unsigned char c){ return std::isspace(c) && c != '\n'; });
    }
    

    If you can’t use a C++ 2011 compiler you’ll need to replace the lambda function by an actual function with the same signature.

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

Sidebar

Related Questions

Hallo There was hopng I could ask for some advice. Which would be the
Please could I ask for some advice on a control flow issue with node
everybody! Could I ask you to help me to decode this JSON code: $json
I would like to ask how could I convert a string which inserted by
First of all, I could not decide if I should ask this here or
i have this code which ask user to input value and submit. html <form
I wonder if I could ask for some advice regarding some work I'm currently
I'm new here. I thought I could ask for some help here on my
Since Embarcadero's NNTP server stopped responding since yesterday, I figured I could ask here:
I just wanna ask if there's a way where I could put an object

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.