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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:10:08+00:00 2026-06-03T01:10:08+00:00

I’ve cut out a lot of the code to make it easier to read.

  • 0

I’ve cut out a lot of the code to make it easier to read. Specifically I’m trying to rewrite strcat

#include <iostream>
using namespace std;

char MYstrcat(char string1[],char string2[]);

int main()
{
    char letter, letter_ans, again;
    const int SIZE = 80;
    char string1 [SIZE];
    char string2 [SIZE];

getting input for the character arrays

    cout << "Enter the first string: ";
    cin >> string1;
    cout << "Enter the second string: ";
    cin >> string2;
    letter_ans=MYstrcat(string1, string2);
    cout << letter_ans;

    cin.get(); cin.get();
    return 0;
}

this is my version of the strcat function

char MYstrcat(char string1[],char string2[])
{ 
    int i = 0; //Counters
    int j = 0;

    //Read until null character is encountered then append.
    while (string1[i] != '\0')
    {
        i++;
    }
    while (string2[j]!= '\0'){
        string1[i] = string2[j];
        i++;
        j++;
    }
    string1[i]='\0'; // Place a null character in string2.

i get the error in this next line: invalid conversion from ‘char*’ to ‘char’

    return string1;
}
  • 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-03T01:10:09+00:00Added an answer on June 3, 2026 at 1:10 am
    char MYstrcat(char string1[],char string2[]); // returns a single character
    char *MYstrcat(char string1[],char string2[]); // returns a pointer to a string that can be used like string1[] and string2[]
    

    Likewise,

    char letter_ans;    // this gives space for a single char, like int int_ans;
    char *letter_ans;   // this makes a pointer to an array of char's, the proper return type
    

    However, since you are returning string1, it may be possible that you don’t even want to use a return type. If you declare your function as so:

    void MYstrcat(char *string1,char *string2);
    

    It will operate directly on string1, leaving no need to return a pointer to it.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.