fork download
  1. char incoming[] = "GET /STA/ID=HelloWorld/Pass=Testin123 HTTP/1.1";
  2.  
  3. String SSID;
  4. String Pass;
  5.  
  6. char *get = strtok(incoming, " ");
  7. char *request = strtok(NULL, " ");
  8. char *rtype = strtok(NULL, " ");
  9.  
  10. void loop()
  11. {
  12.  
  13. if (request != NULL)
  14. {
  15. char *part = strtok(request, "/");
  16. while (part)
  17. { // While there is a section to process...
  18. if (!strcmp(part, "STA"))
  19. {
  20. if (!strncmp(part, "ID=", 3))
  21. { // We have the ID
  22. SSID = String(part + 3);
  23. Serial.print("\n");
  24. Serial.print("SSID: ");
  25. Serial.print(SSID);
  26.  
  27. }
  28.  
  29. if (!strncmp(part, "Pass=", 5))
  30. { // We have the password
  31. Pass = String(part + 5);
  32. Serial.print("\n");
  33. Serial.print("PWD: ");
  34. Serial.print(Pass);
  35. }
  36. }
  37. else
  38. {
  39. Serial.print("\n");
  40. Serial.print("Not Found");
  41. }
  42. part = strtok(NULL, "/");
  43. }
  44. }
  45. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:3:1: error: unknown type name 'String'
String SSID;
^
prog.c:4:1: error: unknown type name 'String'
String Pass;
^
prog.c:6:13: warning: implicitly declaring library function 'strtok' with type 'char *(char *, const char *)'
char *get = strtok(incoming, " ");
            ^
prog.c:6:13: note: include the header <string.h> or explicitly provide a declaration for 'strtok'
prog.c:6:13: error: initializer element is not a compile-time constant
char *get = strtok(incoming, " ");
            ^~~~~~~~~~~~~~~~~~~~~
prog.c:7:24: error: use of undeclared identifier 'NULL'
char *request = strtok(NULL, " ");
                       ^
prog.c:8:22: error: use of undeclared identifier 'NULL'
char *rtype = strtok(NULL, " ");
                     ^
prog.c:13:16: error: use of undeclared identifier 'NULL'
if (request != NULL)
               ^
prog.c:18:12: warning: implicitly declaring library function 'strcmp' with type 'int (const char *, const char *)'
      if (!strcmp(part, "STA"))
           ^
prog.c:18:12: note: include the header <string.h> or explicitly provide a declaration for 'strcmp'
prog.c:20:14: warning: implicitly declaring library function 'strncmp' with type 'int (const char *, const char *, unsigned int)'
        if (!strncmp(part, "ID=", 3))
             ^
prog.c:20:14: note: include the header <string.h> or explicitly provide a declaration for 'strncmp'
prog.c:22:18: warning: implicit declaration of function 'String' is invalid in C99 [-Wimplicit-function-declaration]
          SSID = String(part + 3);
                 ^
prog.c:23:11: error: use of undeclared identifier 'Serial'
          Serial.print("\n");
          ^
prog.c:24:11: error: use of undeclared identifier 'Serial'
          Serial.print("SSID: ");
          ^
prog.c:25:11: error: use of undeclared identifier 'Serial'
          Serial.print(SSID);
          ^
prog.c:32:11: error: use of undeclared identifier 'Serial'
          Serial.print("\n");
          ^
prog.c:33:11: error: use of undeclared identifier 'Serial'
          Serial.print("PWD: ");
          ^
prog.c:34:11: error: use of undeclared identifier 'Serial'
          Serial.print(Pass);
          ^
prog.c:39:11: error: use of undeclared identifier 'Serial'
          Serial.print("\n");
          ^
prog.c:40:11: error: use of undeclared identifier 'Serial'
          Serial.print("Not Found");
          ^
prog.c:42:21: error: use of undeclared identifier 'NULL'
      part = strtok(NULL, "/");
                    ^
4 warnings and 15 errors generated.
stdout
Standard output is empty