Guest User

Untitled

a guest
Apr 9th, 2020
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1.  
  2. #include <conio.h>
  3. #include <stdint.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6.  
  7. void exeCMD(char *cmd, char *params)
  8. {
  9.     if (params == NULL) { printf("null params\n"); } else {
  10.     printf("Komanda %s - Params %s", cmd, params); }
  11. }
  12.  
  13. void checkParams(char *cmd, char *commands)
  14. {
  15.     char *param = NULL;
  16.     char params[64];
  17.  
  18.     printf("Komanda %s - Ostale %s\n", cmd, commands);
  19.  
  20.     /*if (!strcmp(cmd, "RTC_Set"))
  21.     {
  22.         // FIRST PARAM
  23.         param = strtok(commands, ",");
  24.         strcat(params, param);
  25.  
  26.         // OTHER PARAMS
  27.         for (uint8_t i = 1; i < 2; i++)
  28.         {
  29.             param = strtok(NULL, ",");
  30.             strcat(params, param);
  31.         }      
  32.     }*/
  33.  
  34.     //exeCMD(cmd, params);
  35. }
  36.  
  37. void parseCommands(char *commands)
  38. {
  39.     char *cmd = NULL;
  40.  
  41.     // FIRST COMMAND
  42.     cmd = strtok(commands, ",");
  43.  
  44.     // OTHER COMMANDS
  45.     while (cmd != NULL)
  46.     {
  47.         checkParams(cmd, commands);
  48.         cmd = strtok(NULL, ",");
  49.     }
  50. }
  51.  
  52. int main()
  53. {
  54.     char commands[64];
  55.  
  56.     printf("Upisi komande: ");
  57.     scanf("%s", &commands);
  58.  
  59.     parseCommands(commands);
  60.  
  61.     getch();
  62.     return (0);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment