Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include<iostream>
- #include<string>
- using namespace std;
- void split(string input, string delimiter,string output[]) {
- string op = input;
- size_t pos = 0;
- string token;
- string a[100];
- int i = 0;
- while ((pos = op.find(delimiter)) != string::npos) {
- token = op.substr(0, pos);
- a[i] = token;
- output[i] = a[i];
- i++;
- op.erase(0, pos + delimiter.length());
- }
- output[i] = op;
- }
- int main()
- {
- string abc = "var URL = RequestProtocol + / + RequestHost + RequestPort + RequestPath+ ? + RequestQuery; echo(URL);";
- string out[100];
- split(abc, "+",out);
- size_t size = sizeof(out) / sizeof(out[0]);
- for (int i = 0;i < size;i++) {
- cout << out[i]<<endl;
- if (out[i] == "")
- break;
- }
- cout << endl << endl;
- split(abc, "=", out);
- for (int i = 0;i < size;i++) {
- cout << out[i] << endl;
- if (out[i] == "")
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement