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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:49:50+00:00 2026-06-06T23:49:50+00:00

Successfully created a string vector for storing the entries. A while loop asks for

  • 0

Successfully created a string vector for storing the entries. A while loop asks for ToDo Items and a SHOW key shows the user all items currently stored in the string vector. For easier access to the items I have an int just displays “running” numbers in fron the items.

After user has added few items he can type DEL what brings him to the deletion mode:
(Here I like to enter 2 what will delete Stop Smoking and rearrange the array to fill
the gap)

enter image description here

Now I like to get the number the user enteres, decrement with 1 to match to the
vector array index number and delete the entry but whats the best approach to do this?

This is how I get the items added to the string vector:

int taskNumber = 1;
cout<<"New task: ";
getline (cin,newTaskEntry);
taskVector.push_back(newTaskEntry);

cout<<"TOTAL TASKS IN YOUR INBOX: "<<taskVector.size()<<endl;

This is how I show the user all entries:

for (vector<string>::iterator i = taskVector.begin(); i != taskVector.end(); ++i) 
            {
                cout<<taskNumber<<"  ";
                cout<<*i<<endl;
                taskNumber = taskNumber +1; 
            }
  • 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-06T23:49:51+00:00Added an answer on June 6, 2026 at 11:49 pm

    Do just:

    cin >> number;
    if(number > 0 && number < taskVector.size())
    {
        vector<string>::iterator it(taskVector.begin() + number - 1);
        taskVector.erase(it);
    }
    else
        cout << "Error. Out of bounds\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've successfully created my application's Settings.bundle and the items I need within it. I
I have successfully created my own virtual path provider to load a user control
I have successfully created EditTexts depending on the user input in Android, and also
I successfully created database on my local server using Code First, migrated it to
I successfully created a project using Wicket quickstart and turned it into an Eclipse
I have successfully created a feature in sharepoint that modifies the existing edit dialog
I've successfully created a WCF service that works how I want it to. The
I have successfully created a custom Facebook open graph action, and have been able
i have successfully created distribution profiles and installed on my xcode organiser, but this
I have successfully created an application which is workable on the >3.0 devices. However,

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.