project/weight.c
/**
 * Appends current user's weight log with new entry.
 */
Appends current user's weight log with new entry.
Appends current user ' s weight log with new entry .
void addLog(int weight, char * time)
{
  if (users[currentUser].name)
  {
    int lastLogIndex = users[currentUser].numLogs - 1;
    struct log lastLog = users[currentUser].logs[lastLogIndex];
    int id = lastLog.id + 1;
    struct log nLog;
    nLog.id = id;
    nLog.weight = weight;
    nLog.time = time;
    users[currentUser].logs[lastLogIndex + 1] = nLog;
    users[currentUser].numLogs++;
    saveToJson();
  }
}
void addLog ( int weight , char * time ) { if ( users [ currentUser ] . name ) { int lastLogIndex = users [ currentUser ] . numLogs - 1 ; struct log lastLog = users [ currentUser ] . logs [ lastLogIndex ] ; int id = lastLog . id + 1 ; struct log nLog ; nLog . id = id ; nLog . weight = weight ; nLog . time = time ; users [ currentUser ] . logs [ lastLogIndex + 1 ] = nLog ; users [ currentUser ] . numLogs ++ ; saveToJson ( ) ; } }
Appends current user's weight log with new entry.
Appends current user ' s weight log with new entry .
//printf("-----addLog()-----\n"); // Create ID by adding one to last log // Make new log // Add log to user