i made function separates 1 of data points eliminate character.i want add r: g: b: 3 numbers. example if values 255,0,0 becomes
255 0 0
i want
r:255 g:0 b:0
this function made separate commas.
#include string void rgb(string input) { istringstream ssstring(input); while (getline(ssstring, input, ',')) cout<< input << endl; }
you can iterate through array of prefixes. sufficient.
const char *prefix[3] = { "r:", "g:", "b:" }; for( int p = 0; p < 3 && getline(ssstring, input, ','); p++ ) { cout << prefix[p] << input << endl; }
Comments
Post a Comment