Advertisement
Sc3ric

key-val-sep

Mar 24th, 2023 (edited)
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. void keyValueSeparator(char* str, char** key, char** val) {
  2.     int i = 0, j = 0, k = 0;
  3.     int beforeEq = 1;
  4.  
  5.     *key = new char[1000];
  6.     *val = new char[1000];
  7.  
  8.     while (str[i] != '\0') {
  9.         if (str[i] == '=') {
  10.             beforeEq = 0;
  11.         }
  12.         else {
  13.             if (beforeEq) {
  14.                 (*key)[j++] = str[i];
  15.             }
  16.             else {
  17.                 (*val)[k++] = str[i];
  18.             }
  19.         }
  20.        
  21.         i++;
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement