Anonymous
The return statement must be the only statement in the function
Anonymous
boolean
It's not a keyword in C++
Anonymous
this?
Anonymous
It's not a keyword in C++
I'm saying function returns boolean type values
Anonymous
Anonymous
i did it to all the other functions
Bojan_Krdemn
Hey! when reading text file is is_open() method enough to check the end of file? I guess no, so if (!ifstream.eof) condition must be added, mustn't it?
Artöm
is_open doesnt check eof
Artöm
It literally checks if file is opened
Artöm
Eof reach doesnt cause automatic close
Bojan_Krdemn
so if my goal is to select triples of words triple by triple What must be present? if (infile.is_opened) if (infile.isgood()) Unlike the case of reading line by line or word by word (char by char) i can't put loop into while() as in while (is.get(c))
Bojan_Krdemn
must the body of loop contain chechs for EOF condition? To guarantee that in case where the number of words != 3*N loop won't give exception
Реда ✨
Hey happy to be with you fam
Anonymous
Anonymous
Hello
Anonymous
I' looking on std::map
Anonymous
I'sorry I can not share the link :)
Anonymous
but anyway
Anonymous
why there is the function equal_range in std::map
Anonymous
but not a way to insert multiple items for one key?
Anonymous
Please, has anybody some idea?
Javi
A map is a one to one relational container
Javi
You cannot have multiple items for one key
Javi
For that, you have to use multimap
Anonymous
Why isnt it printing?
Anonymous
Please help
Anonymous
Why isnt it printing?
/warn screen photo
Anonymous
Okay now just please help me
Talula
Why isnt it printing?
Because if you divide anything by 2 it'll never be 0 unless it i = 0
Talula
If you want to use Mod it's not / it's %
Anonymous
Ah okay
Anonymous
Thank you so much and please remove the warning i didnt know that i could send screenshots
Anonymous
Thank you so much and please remove the warning i didnt know that i could send screenshots
No, I won't You should have read the rules, but you haven't
telusukoni em Chestav
telusukoni em Chestav
Can any one tell this program
Pavel
Can any one tell this program
You need a for loop and a second counter to go over the characters of the first string and compare with a character from the second string (from the position of the second counter) if they match increase the second counter, if they don't, put the character into the resulting string/vector.
Pavel
But I won't be surprised if STL already has an algorithm for that
Pavel
Also, this won't work for some extended UTF-8 stuff, that you would need if it was something that you wrote for a real app
Pavel
What is stl
C++ standard library It contains containers, algorithms and almost all the basic stuff you usually need while writing something useful. I suggest you to google it.
klimi
MᏫᎻᎯᎷᎷᎬᎠ
Welcome
Asanali
hello
MᏫᎻᎯᎷᎷᎬᎠ
Hi
Asanali
I'm new to C and programming, so i would like to learn about it through books and sometimes asking kind people in the chat :)
Asanali
I started reading C: Modern Approach, is it enough for now?
Augmented
Why a sorted array's processing is faster than unsorted ?
Dan
hmm.. it depends what you mean by processing
Augmented
vector<int> v(1'000'000);     iota(v.begin(), v.end(), 0);
Augmented
sort(v.begin(), v.end());
MᏫᎻᎯᎷᎷᎬᎠ
Asanali
Sorry I'm not an expert in C
is this chat mainly about c++?
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
What does this do?
Assign every element in the vector with an increased value of int
Anmol
What does this do?
Search google for "vector in c++"
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
And so on
Talula
v[0]=0; v[1] =1; v[2]=2;
iota(v.begin(), v.end(), 0); THIS!!
Augmented
is this chat mainly about c++?
C++ is a different - much modern language, but it is based on C, and shares it's ecosystem... so everything you learn for C, will me more or less upwards compatible...
MᏫᎻᎯᎷᎷᎬᎠ
olli
template< class ForwardIt, class T > void iota( ForwardIt first, ForwardIt last, T value ); "Fills the range [first, last) with sequentially increasing values, starting with value and repetitively evaluating ++value." https://en.cppreference.com/w/cpp/algorithm/iota
Talula
So the array is already sorted...
Talula
If it's going to put the numbers in sorted order.
MᏫᎻᎯᎷᎷᎬᎠ
Talula
So where is the question?
Anonymous
XD @BinaryByter
Well, it's true
Augmented
std::shuffle(v.begin(), v.end(), std::mt19937{ std::random_device{}() });
MᏫᎻᎯᎷᎷᎬᎠ
Why a sorted array's processing is faster than unsorted ?
For example In sorted elements, binary search is usually performed
MᏫᎻᎯᎷᎷᎬᎠ
If you want the maximum element You just pick the last one O(0) Or the first one for the minimum