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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:16:32+00:00 2026-05-23T10:16:32+00:00

As simple as that. I’m on C++ btw. I’ve read the cplusplus.com’s cstdlib library

  • 0

As simple as that. I’m on C++ btw. I’ve read the cplusplus.com’s cstdlib library functions, but I can’t find a simple function for this.
I know the length of the char, I only need to erase last three characters from it. I can use C++ string, but this is for handling files, which uses char*, and I don’t want to do conversions from string to C char.

  • 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-23T10:16:32+00:00Added an answer on May 23, 2026 at 10:16 am

    If you don’t need to copy the string somewhere else and can change it

    /* make sure strlen(name) >= 3 */
    namelen = strlen(name); /* possibly you've saved the length previously */
    name[namelen - 3] = 0;
    

    If you need to copy it (because it’s a string literal or you want to keep the original around)

    /* make sure strlen(name) >= 3 */
    namelen = strlen(name); /* possibly you've saved the length previously */
    strncpy(copy, name, namelen - 3);
    /* add a final null terminator */
    copy[namelen - 3] = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi everyone this is probably something extremely simple that i'm overlooking but can someone
I am sure this is probably something simple that i am not doing. Running
I know this is probably something so simple that I am just not able
Ok, This seem so simple that I feel kind of dumb for asking, yet
Binary heaps are so simple that they are almost always used when priority queues
I have a regex 'simple' that I'd like to use as a building block
I just need a button so simple that it looks like a TextBlock. Some
I'm not sure if it's a bug or something simple that I just missed...
I have a script that generates content containing certain tokens, and I need to
I have a reasonable size flat file database of text documents mostly saved in

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.