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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:43:17+00:00 2026-06-10T16:43:17+00:00

I wrote the following method: void ShowInfo::show_time(){ time_t rawtime; struct tm *ti; time (

  • 0

I wrote the following method:

void ShowInfo::show_time(){
  time_t rawtime;
  struct tm *ti;

  time ( &rawtime );
  ti = localtime ( &rawtime );

  std::cout << std::setw(2) << ti->tm_hour << ":"
            << std::setw(2) << ti->tm_min << ":"
            << std::setw(2) << ti->tm_sec;
}

Is it necessary to delete the struct ti to free memory, or it’s going to be deleted when the method ends?

And if it’s necessary to delete it, how do i do it?

  • 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-10T16:43:18+00:00Added an answer on June 10, 2026 at 4:43 pm

    You should check this with the documentation. A cursory search in google indicates that:

    [http://en.cppreference.com/w/cpp/chrono/c/localtime]:

    Returns: pointer to a static internal std::tm object on success

    [http://msdn.microsoft.com/en-us/library/aa246456(v=vs.60).aspx]

    Remarks: gmtime, mktime, and localtime all use a single statically allocated tm structure for the conversion.

    So it seems that there is no dynamic allocation in place, and thus no need to release the memory back to the system.

    More than the actual answer, you should understand that memory management is part of the interface of a function and must be documented. The docs are the simplest place to look for this information. Specially if you had to release the memory, the documentation would surely point this out.

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

Sidebar

Related Questions

Good day all I wrote the following method: private void RegisterEvent(object targetObject, string eventName,
I've enabled ARC, In my didFinishLaunchingWithOptions method, I wrote the following code: AppDelegate.h: @interface
I wrote following function void validateUser(void) { string uName; string uPassword; char c; map
I wrote the following method that receives a list and updates the database based
I wrote a setter and getter method following Apple's conventions and noticed that despite
I wrote the following piece of code: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ GameViewController *gameViewController =
I have the following method public void ValidateAccessToFile(string filePath, List<String> errorMessageList) { try {
I wrote the following code for finding square root by Newton's method by successive
I wrote the following method to remove the namespace in brackets from strings. I
Using an idea from Bob King idea I wrote the following method. It works

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.