Advertisement
Looz_Dreemur

STDCXX PSEUDOCODE

Nov 18th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. void init()
  2. initialise %appdata% location
  3. initialise cache files location (cache.txt and cache.bin)
  4. RETURN
  5.  
  6.  
  7. void getUserMenuChoice(char buffer[], int size, char *errMsg)
  8. WHILE TRUE
  9. use fgets() to get userinput
  10. trimmedCharArr = trimwhitespace(buffer)
  11. IF trimmedCharArr have string length not equal to 1
  12. print errMsg
  13. CONTINUE
  14. END IF
  15. BREAK
  16. END WHILE
  17. string copy trimmedCharArr back to buffer
  18. RETURN
  19.  
  20.  
  21. int chkFileExist(char *dir)
  22. Open file pointer pointing to dir
  23. IF file opened successfully
  24. Check file size
  25. IF file size == 0
  26. close file pointer
  27. RETURN 0
  28. END IF
  29. close file pointer
  30. RETURN 1
  31. END IF
  32. RETURN 0
  33.  
  34.  
  35. char *trimmedCharArr(char *str)
  36. WHILE str is pointing at space character
  37. move str pointer to the right by 1
  38. END WHILE
  39. IF str ended up pointing to '\0'
  40. RETURN str
  41. initialise end pointer pointer to last character of the str
  42. WHILE end pointer is pointing at space character
  43. move end pointer to the left by 1
  44. END WHILE
  45. null terminate the trimmed str (end[1] = '\0')
  46. RETURN str
  47.  
  48.  
  49. s_input(char *str, int size)
  50. rewind standard input
  51. use fgets() to get userinput
  52. Remove '\n' from input (becausee fgets() collect '\n')
  53. rewind standard input
  54. RETURN
  55.  
  56.  
  57. void getSystemDate(char dateVar[])
  58. Get systemdate and store in dateVar provided
  59. RETURN
  60.  
  61.  
  62. void getSystemTime(char timeVar[])
  63. Get systemtime and store in timeVar provided
  64. RETURN
  65.  
  66.  
  67. int validateDate(int dd, int mm, int yy)
  68. Checks for lunar years and month-end dates
  69. IF any tests failed
  70. RETURN 0
  71. END IF
  72. RETURN 1
  73.  
  74.  
  75. int validateTime(int h, int m, int s)
  76. checks for invalid time (negative numbers and such)
  77. IF any tests failed
  78. RETURN 0
  79. END IF
  80. RETURN 1
  81.  
  82.  
  83. int compareTime(int h1, int m1, int s1, int h2, int m2, int s2)
  84. IF both time are the same
  85. RETURN 0
  86. END IF
  87. Compare hours, minutues then seconds
  88. IF any inequalities found
  89. RETURN 1 if time1 is later than time2
  90. RETURN -1 if time2 is later than time1
  91. END IF
  92.  
  93.  
  94. int compareDate(int dd1, int mm1, int yy1, int dd2, int mm2, int yy2)
  95. IF both date are the same
  96. RETURN 0
  97. END IF
  98. Compare years, months, days
  99. IF any inequalities found
  100. RETURN 1 if date1 is later than date2
  101. RETURN -1 if date2 is later than date1
  102. END IF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement