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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:56:53+00:00 2026-06-18T15:56:53+00:00

I am working on a school assignment and I am having trouble figuring out

  • 0

I am working on a school assignment and I am having trouble figuring out how to merge
these two arrays. I have to merge half of each array together into a third array. I am turning my tires, an I think I am over thinking what I have to do. I do not want to waste your time explaining all the things I have tried. Any help would be appreciated, also if you post any code can you explain to me what it is doing, because I want to understand what is happening (as much as possible) Thanks in advance!

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SIZE 254    

int main()
{

Capturing the string here using user input

    char string_1[SIZE];
    printf( "Please enter a long string: " );
    fgets ( string_1, SIZE, stdin );

Getting the string length to calculate byte sizes

    size_t ln = strlen(string_1) - 1;
    if (string_1[ln] == '\n')
        string_1[ln] = '\0';    

Repeated…

    char string_2[SIZE];
    printf( "Please enter a long string: " );
    fgets ( string_2, SIZE, stdin );
    size_t ln2 = strlen(string_2) - 1;
    if (string_1[ln2] == '\n')
        string_1[ln2] = '\0';

Printing the byte size of the two strings.

    printf("String 1 is %zu bytes long, and String 2 is %zu bytes long", ln, ln2);  

I would like to concat

    return 0;


}
  • 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-18T15:56:53+00:00Added an answer on June 18, 2026 at 3:56 pm

    check this code which uses strncpy

    char string_3[2*SIZE + 1];    
    strncpy(string_3, string_1, strlen(string_1)/2);
    string_3[strlen(string_1)/2] = '\0';
    strncpy((string_3 + strlen(string_3)), string_2, strlen(string_2)/2);
    string_3[strlen(string_1)/2 + strlen(string_2)/2] = '\0';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im working on a school assignment, and im supposed to make a array of
I'm working on a school assignment and I'm having an issue with a 2d
I am working on a school assignment that requires operator overloading. I am having
For a school assignment me and a friend have been working on rendering a
I have this school assignment that I've been working on and am totally stumped
I am working on a short assignment from school and for some reason, two
I am working on a school assignment in java and i have come across
I am working on a school assignment that requires me to be able to
I'm working on a school assignment and I've been completely stumped with this step.
I am working on a school project (if you couldn't figure that out just

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.