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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:17:48+00:00 2026-06-11T10:17:48+00:00

what I am trying to do is to modify simple linked list so far

  • 0

what I am trying to do is to modify simple linked list so far i have a functions to input a name, then output with reverse order, but i’m having trouble changing character at a specific location.

main code:

#include "list.h"
#include "string"
using namespace std;
int main(){
    cout<<"What is your name \n";
    string name;
    getline(cin,name);

    Node *list;

    list = new_list();                           
    for (int i=0; i<name.length();i++){
    insert_front(&list,name[i]);
    }                              
    print_list(list);                    
    int p;
    char x;
    cout<<"Change the position: ";
    cin>>p;
    cout<<"\n to the character " ;
    cin>>x;
    change_char(list, x, p);
    print_list(list);
    return 0;
}

and my list.cpp

#include "list.h"                            
Node* new_list(){
    Node* list = 0;
    return list;
}
void insert_front(Node** plist,char x){
    Node* t;
    t = new Node;
    t->x = x;
    t->next = *plist;
    *plist = t;
    return;
}
void print_list(Node* list){
    Node* p;
    p = list;
    if(p == 0)
        cout << "--- empty list ---" << endl;
    while(p !=0){
        cout << p->x<<" -- ";
        p = p->next;
    }
    cout << endl;
}
void delete_front(Node** plist){
    Node* t;
    if( !is_empty(*plist) ){                            
        t = (*plist)->next;
        *plist = (*plist)->next;
        delete t;
    }
}
void delete_list(Node** plist){
    while( !is_empty(*plist) )                         
        delete_front(plist);
}
bool is_empty(Node* list){
    return (list == 0);                            
}
void change_char(Node* plist, char x, int p){
    Node* s;
    s=(plist->next);
      cout<<s<<endl;
      cout<<plist<<endl;
 return;

I’m stack on how to change character at a specific position. the change_char gives me back an address, but not a list, i’m not sure whats wrong.

Also how would the change in character be different from insertion and deletion of character.
Thanks for any help

  • 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-11T10:17:49+00:00Added an answer on June 11, 2026 at 10:17 am

    Insertion = appending a char to the list; Deletion = removing a char from the list

    I’d hope those would be obvious.

    Changing at a position requires you walk the list to that position. You can do it iteratively or recursively, your choice. Assuming your positions are 1-based (as opposed to 0-based (and this code is NOT test compiled, so use at your own peril):

    void change_char(Node* plist, char x, int p)
    {
        Node* s = plist;
        for (int i=1; i<p && 0!=s;i++)
           s = s->next;
        if (0 != s)
           s->x = x;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple proxy source in C++. I'm trying to modify it to
I'm trying to modify an svg tag with javascript to make it resizable, but
I am trying to modify the code below to check the input from a
i am trying to modify one js file validation rule but unable to do
I am trying to modify a batch script that installs a simple script file
I'm trying to modify this example: http://jqueryui.com/demos/autocomplete/#combobox to parse a similar select list, in
I have a shopping cart script that I am trying to modify to support
I'm trying to modify my simple Twisted web proxy to use Proxy-Authentication (username/password) instead
I'm trying to modify a simple dynamic vector in CUDA using the thrust library
I have implemented the regula falsi method. I am trying to modify it so

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.