Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. void add(char* time1, char* time2){
  2. num_seconds_t seconds1, seconds2, total;
  3. struct time_spec_t *spec1 = malloc(sizeof(spec1));
  4. struct time_spec_t *spec2 = malloc(sizeof(spec2));
  5. struct time_spec_t *total_time = malloc(sizeof(total_time));
  6.  
  7. if ((is_legal_seconds(time1))) {
  8. seconds1 = string_to_seconds(time1);
  9. } else if ((is_legal_time_spec(time1))) {
  10. spec1 = string_to_time_spec(time1);
  11. seconds1 = time_spec_to_seconds(spec1);
  12. } else {
  13. //error
  14. }
  15.  
  16. if ((is_legal_seconds(time2))) {
  17. seconds2 = string_to_seconds(time2);
  18. } else if ((is_legal_time_spec(time2))) {
  19. spec2 = string_to_time_spec(time2);
  20. seconds2 = time_spec_to_seconds(spec2);
  21. } else {
  22. //error
  23. }
  24.  
  25. total = seconds1 + seconds2;
  26. if (total < 3155760000){
  27. total_time = seconds_to_time_spec(total);
  28. print_time_spec(total_time);
  29. exit(0);
  30. } else {
  31. fprintf(stderr,"Error adding time");
  32. exit(0);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement