Copy each word to other array
Nov 11, 2015 at 9:26pm UTC
Hello i have a problem. I need create a function whose split my char
"Ala ma kota, a kot ma ale" and each save in other array, then copy all these words to one array and show. I dont now how save each word in other array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#include <iostream>;
using namespace std;
int main(){
string fCiagi(char * lista);
char znaki[]= "Ala ma kota, a kot ma ale" ;
char *wsk1;
wsk1= &*znaki;
cout<<"char: " << znaki[4]<<endl;
cout<<"wsk1(char): " << wsk1[4]<<endl;
fCiagi(wsk1);
}
string fCiagi(char * lista){
int dlugWsk1=0;
while (lista[dlugWsk1] != '\0' )
dlugWsk1++;
char tab0[100];
char tab1,tab2,tab3,tab4,tab5,tab6,tab7;
cout<<lista[dlugWsk1]<<endl;
for (int i=0; i<dlugWsk1; i++){
tab0[i]=lista[i];
if (lista[i] != ' ' ){
cout<<lista[i];
}else {
cout<<endl;
}
}
cout<<endl;
cout<<tab0<<endl;
}
Topic archived. No new replies allowed.