0
void slova(string datoteka){
    ifstream coban;
    coban.open(datoteka.c_str());
    string polje[200];
    string linija;
    int brojac=0;
    while(!coban.eof()){
    getline(coban,linija);
    polje[brojac]=linija;
    brojac++;
}   

string rec=polje[1];
int brojac2=0;
for(int i=0;i<rec.length();i++){brojac2++;}
cout<<brojac2<<endl;
        
   if(rec[0]==rec[brojac2]){cout<<"same letters"<<endl;}
   else{cout<<"letters are not same"<<endl;}
}

This is my code, it should test if 1st and last letter in string are same, but i can't get it to work.

Please somebody help me, i would really appreciate it.

Thank you in advance.

2
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by n3r3d
0

maybe rec[0] == rec[rec.length()-1]

Thank you man, you are my hero, its working perfrect. :))

Have a nice day!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.