Answer the question
In order to leave comments, you need to log in
How to modify the code correctly?
There is a code that leaves only the first occurrences of letters. How can the code be improved so that it does not take one word, but a whole sentence?
Here is the code itself:
#include "stdafx.h"
#include <iostream>
bool exist[128];
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
char str[256];
cout << "Введите строку:";
cin >> str;
for (int i = 0; str[i]; i++)
if ( !exist[ str[i] ] )
{
cout << str[i];
exist[ str[i] ] = true;
}
cout << endl;
system("pause");
return 0;
}
Answer the question
In order to leave comments, you need to log in
std::string buffer;
std::getline (std::cin, buffer); // Линия с консоли с пробелами и всем прочим
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question