Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// string test
- #include <iostream>
- #include <string>
- using namespace std;
- void mapdatatogrid(string mapdata);
- int main()
- {
- /// define map
- string mapdata;
- /// append map
- mapdata.append("!-6:-4:A:3:3!2:-4:A:3:3!-6:-4:A:3:3!-6:-4:A:3:3");
- mapdatatogrid(mapdata);
- return 0;
- }
- void mapdatatogrid(string mapdata)
- {
- unsigned int findfirstcluster;
- unsigned int findclusterend;
- bool decluster = true;
- /// find first cluster
- findfirstcluster=findfirstcluster = mapdata.find("!");
- /// check clusting
- do
- {
- /// test first cluser
- if(findfirstcluster!=string::npos||findfirstcluster==0)
- {
- /// find the cluster end
- findclusterend=mapdata.find("!",findfirstcluster+1);
- if(findclusterend==0||findclusterend==string::npos)
- {
- decluster=false;
- cout << "break";
- break;
- }
- else
- {
- string newstring = mapdata.substr(findfirstcluster+1,(unsigned int)findclusterend-(findfirstcluster+1));
- cout << newstring.c_str() << endl;
- findfirstcluster = mapdata.find("!",findfirstcluster+1);
- }
- }
- }
- while(decluster==true);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment