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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:40:22+00:00 2026-05-10T20:40:22+00:00

Okay i am working on someone elses code. They do alot of this: char

  • 0

Okay i am working on someone elses code. They do alot of this:

char description[256]; description[0]=0; 

I know this would put a \0 in the first spot of the character array. But is this even a safe way to erase a string?

Also visual studio keeps reporting memory leaks, and i’ve pretty much tied this done to the strings that are used.

Ps. Yes i know about std::string, yes i use that. This isn’t my code.

  • 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. 2026-05-10T20:40:22+00:00Added an answer on May 10, 2026 at 8:40 pm

    To initialize the string to 0, you could do:

    char description[256] = {0}; 

    that will assign 0 to every element of the array.

    Just setting the first element to 0 ('\0') does not erase it’s contents. It doesn’t even guarantee the entire string is set to the null character.

    As stated by others, you can’t ‘erase’ statically-created objects until the function closes, when it gets abandoned. Technically, it’s not erased when the function is abandoned either – the stack pointer is merely changed. If you’re paranoid about the data being erased, you should iterate through the array, setting each entry to 0 ('\0').

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

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Basically yes. These paths are basically resolved first by php/apache… May 11, 2026 at 10:09 am
  • added an answer I have a hunch that the problem here is the… May 11, 2026 at 10:09 am
  • added an answer What's wrong with putting a newline after each period? Eg:… May 11, 2026 at 10:09 am

Related Questions

Okay i am working on someone elses code. They do alot of this: char
Okay, that may not be the best subject... I am setting up an approval
Okay I'm still learning the ropes with the Entity Framework and I came across
Okay I know I asked about this before, and the answer was basically cache
Okay I have this RewriteRule which is supposed to redirect any request for the
Okay so I've read the documentation, and I'm not quite sure what the arguments
Okay so I have the following Code which appends a string to another in
Okay so I have a scenario similar to the below code, I have a
Okay here's the program I have typed up(stdio.h is included also): /* function main
Okay, I've looked all over the internet for a good solution to get PHP

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.