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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:09:18+00:00 2026-05-23T14:09:18+00:00

I have a .txt file containing 2 columns . I have to search for

  • 0

I have a .txt file containing 2 columns . I have to search for a pattern in the first column and delete that line from the file that matches .

I have to do this inside a c++ program.

What are the options I could use ?

I though of using a system() function and call sed (which seems efficient). But I’m not sure how to use sed inside system ().
The search pattern is a c++ variable and I’m not sure how to insert it inside sed

int pattern;
.
.
.

system ("sed -i '/pattern/d' file.txt");

I know it could take this form, but I appreciate any help from you, about how to use c++ variable as a search pattern inside sed

  • 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-23T14:09:19+00:00Added an answer on May 23, 2026 at 2:09 pm

    assemble in a std::string and then use c_str(). You might find ostringstream (from sstream header) useful for assembling the string.

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

Sidebar

Related Questions

I have a file address.txt containing `0x0003FFB0' at line 1 and column 2 i
I have a txt file that created in notepad , containing these lines for
I have a text file (txt) containing formatted text (just line breaks, carriage returns
I have a .txt file containing data like this: 1,Rent1,Expense,16/02/2010,1,4000,4000 1,Car Loan1,Expense,16/02/2010,2,4500,9000 1,Flat Loan1,Expense,16/02/2010,2,4000,8000
I have a .txt file containing data like this: 0,Rent1,Expense,16/02/2010,1,4000,4000 0,Car Loan1,Expense,16/02/2010,2,4500,9000 0,Flat Loan1,Expense,16/02/2010,2,4000,8000
I have a txt file containing on each line 2 values separated by a
I have a txt file containing lines as follows (the first field is keywords,
I have a 'data.txt' file containing two columns and N rows, corresponding to N
I've have a .txt file containing an NSString (encrypted using a private key) that
i have a .txt file containing data like: He: 22.1 Ar: 21.1 K: 1.22

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.