string

what is the problem with this code???i want 2 find gow many space int my every name??

#include<iostream>
#include<string>

using namespace std;

int main(){
int c[5],space[5];

string name[5];

for(int i=0;i<5;i++){
cout<<"Enter Name :";
getline(cin,name[i]);

}

c[5]=0;
for (int i=0;i<5;i++){

c[i]=name[i].size();
cout <<endl << "name " << c[i] ;
}



space[5]=0;
for(int i=0;i<c[5];i++){
if(name[i] == ' '){
space[i]=i;
}
cout << endl << "total space" << space[i];
}
}

Last edited on
Ive told you multiple times before to use code tags. Once you edit your post and use them I'll help you out - http://www.cplusplus.com/articles/jEywvCM9/
#include<iostream>
#include<string>

using namespace std;

int main(){
int c[5],space[5];

string name[5];

for(int i=0;i<5;i++){
cout<<"Enter Name :";
getline(cin,name[i]);

}

c[5]=0;
for (int i=0;i<5;i++){

c[i]=name[i].size();
cout <<endl << "name " << c[i] ;
}



space[5]=0;
for(int i=0;i<c[5];i++){
if(name[i] == ' '){
space[i]=i;
}
cout << endl << "total space" << space[i];
}
}
Try again. Its under the format section. Edit Your first post, dont post again, just edit it. Mark all of your code so its blue, and then press <>. Or just follow the stuff the link says http://www.cplusplus.com/articles/jEywvCM9/
<#include<iostream>
#include<string>

using namespace std;

int main(){
int c[5],space[5];

string name[5];

for(int i=0;i<5;i++){
cout<<"Enter Name :";
getline(cin,name[i]);

}

c[5]=0;
for (int i=0;i<5;i++){

c[i]=name[i].size();
cout <<endl << "name " << c[i] ;
}



space[5]=0;
for(int i=0;i<c[5];i++){
if(name[i] == ' '){
space[i]=i;
}
cout << endl << "total space" << space[i];
}
}>
i am saying u 2 check my codee??
Sorry, but I don't have an obligation to check your code, nor anything else ever. If you choose to ignore what I say completely, even though I've said it and giving you instructions over 5 times now, I will simply choose to ignore you.
Topic archived. No new replies allowed.