Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<iostream>
  6. #include<string>
  7. using namespace std;
  8.  
  9.  
  10. void split(string input, string delimiter,string output[]) {
  11. string op = input;
  12. size_t pos = 0;
  13. string token;
  14. string a[100];
  15. int i = 0;
  16. while ((pos = op.find(delimiter)) != string::npos) {
  17. token = op.substr(0, pos);
  18. a[i] = token;
  19. output[i] = a[i];
  20. i++;
  21. op.erase(0, pos + delimiter.length());
  22. }
  23. output[i] = op;
  24. }
  25.  
  26.  
  27. int main()
  28. {
  29. string abc = "var URL = RequestProtocol + / + RequestHost + RequestPort + RequestPath+ ? + RequestQuery; echo(URL);";
  30. string out[100];
  31. split(abc, "+",out);
  32.  
  33. size_t size = sizeof(out) / sizeof(out[0]);
  34. for (int i = 0;i < size;i++) {
  35. cout << out[i]<<endl;
  36. if (out[i] == "")
  37. break;
  38. }
  39. cout << endl << endl;
  40.  
  41. split(abc, "=", out);
  42.  
  43.  
  44. for (int i = 0;i < size;i++) {
  45. cout << out[i] << endl;
  46. if (out[i] == "")
  47. break;
  48. }
  49.  
  50.  
  51.  
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement