0

this is the wrong code:

const time_t t = time(NULL);
struct tm *local;
local = localtime(&t);
reach.hour = local->tm_hour;
reach.min = local->tm_min;

I am making a Parking lot System. I want to store a time when the car comes and when the car leaves. But the code is wrong, It show 0x0073fbb8{stack=0x0073fbb8 {0x00000000 , 0xcccccccc {num={...} reach={hour=??? min=??? } leave=...}, ...} ...} NODE * {hour=??? min=??? } Unable to read memory. So I want to know how to store a time? the other codes are no problem.

John Young
  • 57
  • 1
  • 8
  • 1
    Possible duplicate of [How to get current time and date in C++?](https://stackoverflow.com/questions/997946/how-to-get-current-time-and-date-in-c) – Kindle Q Nov 14 '17 at 06:19
  • `localtime()` returns a null pointer on failure. You are not checking for that. If not null, the only possibility left is `reach` being invalid. Please provide a [mcve] that reproduces the error. – Remy Lebeau Nov 14 '17 at 06:40

0 Answers0