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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:54:50+00:00 2026-05-29T06:54:50+00:00

I am trying to split up an array (string1) of n characters into two

  • 0

I am trying to split up an array (string1) of n characters into two character pointers representing i characters (char* first) and n-i characters (char* second) respectively. For the second array, I used

char* second = string1+n; 

What I am wondering is how to use only the first i characters in first. I do not want to allocate more memory for the two arrays, I want to manipulate string1 so that I just point to parts of what is already there.

EDIT:

I cannot edit string1. Can I just cast first somehow to make the length shorter without adding a null character?

  • 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-05-29T06:54:51+00:00Added an answer on May 29, 2026 at 6:54 am

    Unless you allocate more memory you can’t use the “first” as you would any other C string (e.g. passing it to string functions, printf, etc) because it isn’t null terminated at the boundary with “second”.

    You can certainly still get around that in many cases because you know the length, but there’s nothing magical you can do here; the null terminator needs a byte.

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

Sidebar

Related Questions

Trying to split this string 主楼怎么走 into separate characters (I need an array) using
I'm trying to split a string into an array based on the second occurrence
I'm trying to split up a web site into two sections. One which should
I'm trying to split a char* to an array of char* in C. I'm
I am trying to split a string into an array of word pairs in
Im trying to split a String into an Array. In PHP I normally use
I am trying to split the text into words: $delimiterList = array(" ", ".",
Trying to split what the user writes in the text field, into an array
I am trying to split a string into an array. This is the code
I'm trying to split a string into an array of words, however I want

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.