// C++ program to print words in a sentence#include<iostream>#include<string.h>usingnamespace std;voidsplit(string str,string store[]){ string word ="";int a =0;for (auto x : str) {if (x ==' ') // split when see spacebar { cout << word << endl;store[a] = word; a++; word =""; }else { word = word + x; } }store[a] = word; cout << word <<"\n"<< endl;}// Driver codeintmain(){ string str ="A:8 C:9 J:7 K:9"; string store[5];split(str,store); //print store value /*for (int x=0; x<=5;x++){ cout<<store[x]<<endl; }*/return0;}
Assoc. Prof. Wiroon Sriborrirux, Founder of Advance Innovation Center (AIC) and Bangsaen Design House (BDH), Electrical Engineering Department, Faculty of Engineering, Burapha University