{"action":"closed","issue":{"url":"https://api.github.com/repos/appirio-tech/arena-web/issues/674","repository_url":"https://api.github.com/repos/appirio-tech/arena-web","labels_url":"https://api.github.com/repos/appirio-tech/arena-web/issues/674/labels{/name}","comments_url":"https://api.github.com/repos/appirio-tech/arena-web/issues/674/comments","events_url":"https://api.github.com/repos/appirio-tech/arena-web/issues/674/events","html_url":"https://github.com/appirio-tech/arena-web/issues/674","id":156681513,"number":674,"title":"string::substr output is weird","user":{"login":"eudaemon","id":4221431,"avatar_url":"https://avatars1.githubusercontent.com/u/4221431?v=4","gravatar_id":"","url":"https://api.github.com/users/eudaemon","html_url":"https://github.com/eudaemon","followers_url":"https://api.github.com/users/eudaemon/followers","following_url":"https://api.github.com/users/eudaemon/following{/other_user}","gists_url":"https://api.github.com/users/eudaemon/gists{/gist_id}","starred_url":"https://api.github.com/users/eudaemon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eudaemon/subscriptions","organizations_url":"https://api.github.com/users/eudaemon/orgs","repos_url":"https://api.github.com/users/eudaemon/repos","events_url":"https://api.github.com/users/eudaemon/events{/privacy}","received_events_url":"https://api.github.com/users/eudaemon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-05-25T07:31:20Z","updated_at":"2017-08-14T02:38:29Z","closed_at":"2017-08-14T02:38:29Z","body":"Hi,\n\nSomehow, string::substr output is weird.\nTry https://arena.topcoder.com/#/u/practiceCode/1349/2185/2358/1/1349\nHawaiian C++ practice with the following code.\n\n```\n#include <vector>\n#include <string>\n#include <cstring>\n#include <iostream>\n\n#define NON_HAWAIIAN    \"qrtysdfgjzxcvb\"\nusing namespace std;\nclass Hawaiian\n{\npublic:\n    vector <string> getWords(string sentence);\n};\n\nvector <string> Hawaiian::getWords(string sentence)\n{\n    vector<string> result;\n\n    // TODO: First tokenize the string.\n    size_t foundPrev = 0;\n    string delimiter = \" \";\n    for (;;)\n    {\n        size_t foundNext = sentence.find(delimiter, foundPrev);\n        if (foundNext == string::npos)\n            break;\n        string token = sentence.substr(foundPrev, foundNext);\n        cout << \"foundPrev = \" << foundPrev << \", foundNext = \" << foundNext << \", token = \" << token << \" |endl| \";\n        // cout << token << \"|endl|\";\n        char *hawaii_filter = strtok((char*)token.c_str(), NON_HAWAIIAN);\n        if (hawaii_filter) {\n            // Do nothing\n        } else {\n            result.push_back(token);\n        }\n        foundPrev = foundNext + 1;\n    }\n\n    return result;\n}\n```\n\nThis is the input\nTest Case 1 : Hawaii is an island\n\nThis is the output.\nStandard Output: foundPrev = 0, foundNext = 6, token = Hawaii |endl| foundPrev = 7, foundNext = 9, token = is an isl |endl| foundPrev = 10, foundNext = 12, token = an island |endl|\n\nThe output token value of \"sentence.substr(7, 9)\" should be \"is\" not \"is an isl\".\nThe null termination did not seemed to work well.\n\nThanks,\n"}}
{"actor":{"display_login":"eudaemon"}}