Russian letters in the program

The question was asked: 7 years 1 months ago   views: 26
0
#include <iostream> using namespace std; int main(int argc, char *argv[]) { string str;int i; cin >> str; for (int i = 0; i <= str.length() - 1; i++) { if ( str[i] == 'd' ) str[i]= ''; } cout << str[i]; system("PAUSE"); return EXIT_SUCCESS; }

What's the problem? This is due to the fact that I use Russian letters, so???

Asked: 25-06-2012 в 23:07:02
@navi1893, what's the problem??? What You see and consider this to be a problem? What do You expect to see? - 25-06-2012 в 23:49:33
@avp it's just what came out of the program without doing anything. But the problem is solved. Just right now I write there if I have entered 'd' then display 'in', but I what is 't' displays - 25-06-2012 в 23:58:41

Answers   1

0
#include <iostream> #include <string> using namespace std; int main(int argc, char *argv[]) { setlocale( LC_ALL,"Russian" ); //string str;int i; //You place sorry ??? string str; //int i; //are You sure you need this variable ??? //Notify user about what we want from him cout << "Please Input Text: "; //cin >> str; //As you imagine it ? Can vsetaki something like this: getline(std::cin, str); cout << "This you entered:" << str << endl; //for (int i = 0; i <= str.length() - 1; i++) //why do you live like that ? for (int i = 0; i < str.length(); i++) { if ( str[i] == 'd' ) str[i]= ''; } //cout << str[i]; //You just need to print only the last character ? cout << "After the action:" << str << endl; system("PAUSE"); return EXIT_SUCCESS; }
Answered: 25-06-2012 в 23:51:13
thank you! Why I wrote if 'd' to bring 'in' and it outputs me 't'??? @lirik90 - 25-06-2012 в 23:55:04
And yet, the whole departure was because of what? Like error not, except str.length() - 1 - 26-06-2012 в 00:00:26
Else setlocale( LC_ALL,"Russian" ); ...write whatever is 'in' output - 26-06-2012 в 00:04:40
Didn't work, because there's no such definition of operator >> for cin which could be the stream output stuff directly into the string class - 26-06-2012 в 00:06:44
@lirik90, misinform gullible @navi1893 >there is no such definition of operator >> for cin which could be the stream output stuff directly into the string class Operator cin >> s; for the string s; reads the next word from a stream (similar to the format '%s ' to char s[BUFSIZE]; scanf ("%s",s);) - 26-06-2012 в 00:39:10