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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:40:27+00:00 2026-06-17T01:40:27+00:00

I am creating a simple logging program. When a user enters log some_file into

  • 0

I am creating a simple logging program. When a user enters log some_file into the console, the program currently simply receives some basic input from cin, and records it into some_file.

However, instead of implementing my own editor with cin, I’d like to open the Nano editor and let the user edit his message there.

Then, when the message is complete, I’d like my C++ logger to receive it as a string and carry on.

This is exactly what git does on commits.

How can I achieve this?

(Preferably without using tools such as expect, just raw C++ code.)

  • 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-17T01:40:29+00:00Added an answer on June 17, 2026 at 1:40 am

    If you want to use the Nano editor then you need to run the system() function to invoke Nano with a temporary file. Then remove the file later..

    std::string filename = "/tmp/.out." + std::to_string(getpid());
    std::string cmd = "/bin/nano " + filename
    system(cmd.c_str());
    // read from filename
    unlink(filename.c_str());
    

    Update

    If using tmpnam() as suggested by DevSolar

    char filename[L_tmpnam];
    tmpnam(filename);
    std::string cmd  = "/bin/nano " + filename
    system(cmd.c_str());
    unlink(filename);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Was creating a simple console application to do some prototyping and was shocked to
I'm creating a simple file walker to list some files and need to omit
I'm creating a simple program with the possibility to change the language and I
We have a fairly simple program that's used for creating backups. I'm attempting to
What is the best approach to creating a simple multithread safe logging class? Is
I am creating a logging facility for my library, and have made some nice
I'm looking into creating a Plugin structure for a program and making it so
I'm creating a windows DLL library that contains a logging class, the log function
I am creating a simple app to get and post some information on any
I'm creating simple example on JSF. It's small Login application. My problem is duplicate

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.