Dev-Cpp
Dev-Cpp copied to clipboard
Getting an error message :Out of memory
trafficstars
#include
}
cout<<endl;
auto it=m.find(1);
for(auto i=it;it!=m.end();i++)
{
cout<<(*i).first<<" "<<(*i).second<<endl;
}
return 0;
}
for ( auto i = it; it != m.end(); i++ ) // <-------- i != m.end() { . . . } return 0;
#include <map>
#include <iostream>
using namespace std;
int main()
{
map<int, string> m { { 1, "Mahak"} ,
{ 2, "Ravindra"} ,
{ 3, "Sunita"}
};
m.insert({ 4, "Chittoda" });
cout << "before erase" << endl;
for (auto i : m) {
cout << i.first << " " << i.second << endl;
}
cout << endl;
cout << "finding 14 -> " << m.count(14) << endl << endl;
m.erase(3);
cout << "after erase " << endl;
for (auto i : m) {
cout << i.first << " " << i.second << endl;
}
cout << endl;
auto it = m.find(1);
for (auto i = it; i != m.end(); i++) {
cout << (*i).first << " " << (*i).second << endl;
}
return 0;
}
Thanks
On Sun, 5 Jun 2022, 8:50 pm Paul McGee, @.***> wrote:
#include
m.insert({ 4, "Chittoda" }); cout << "before erase" << endl; for (auto i : m) { cout << i.first << " " << i.second << endl; } cout << endl; cout << "finding 14 -> " << m.count(14) << endl << endl; m.erase(3); cout << "after erase " << endl; for (auto i : m) { cout << i.first << " " << i.second << endl; } cout << endl; auto it = m.find(1); for (auto i = it; i != m.end(); i++) { cout << (*i).first << " " << (*i).second << endl; } return 0;}
— Reply to this email directly, view it on GitHub https://github.com/Embarcadero/Dev-Cpp/issues/233#issuecomment-1146832966, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYHTSBFLUJ7XJI2KRNERATLVNTASVANCNFSM5XUTPFMA . You are receiving this because you authored the thread.Message ID: @.***>