Through trial and error, I came to the fact that cin somehow does not close the stream, or that it also immediately fills "\ n" the next field of the dynamic array. Whether prompt I think and as for example for me to make reading before switch that the field with a surname could be filled. 42 -44 line there I have written more comments. Thank you

#include<iostream> #include<windows.h> using namespace std; class Sponsor { public: char name[32]; char surname[32]; double sum; Sponsor (){ cout << "cr"<<endl; } ~Sponsor (){ cout << "del"<<endl; } }; Sponsor* AddStruct(Sponsor* Obj, const int amount); void setData(Sponsor* Obj, const int amount); void showData(const Sponsor* Obj, const int amount); void menu(const int amount); void editData(Sponsor* Obj){ cout << "Π’Π²Π΅Π΄ΠΈΡ‚Π΅ порядковый Π½ΠΎΠΌΠ΅Ρ€ записи для рСдактирования" << endl; int amount, YesOrNot; cin >> amount; cout << "Π Π΅Π΄Π°ΠΊΡ‚ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ записи β„–" << amount << endl; setData(Obj, amount - 1); cout << "Π—Π°ΠΏΠΈΡΡŒ ΠΎΡ‚Ρ€Π΅Π΄Π°ΠΊΡ‚ΠΈΡ€ΠΎΠ²Π°Π½Π°" << endl; } void loadData(const Sponsor* Obj, const int amount); int main() { setlocale(LC_ALL, "rus"); Sponsor* OurSponsors = 0; int sponsorAmount = 0; int YesOrNot = 0; // ΠΏΡ€ΠΎΠ΄ΠΎΠ»ΠΆΠΈΡ‚ΡŒ ΠΈΠ»ΠΈ ΠΎΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ Π²Π²ΠΎΠ΄ Π΄Π°Π½Π½Ρ‹Ρ… int rule = 9; //Ссли ΠΏΡ€ΠΎΠΏΠΈΡΡ‹Π²Π°ΡŽ здСсь Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€ 1 Ρ‚ΠΎ срабатываСт всС Π½ΠΎΡ€ΠΌΠ°Π»ΡŒΠ½ΠΎ ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ° просит ввСсти имя Π° ΠΏΠΎΡ‚ΠΎΠΌ Ρ„Π°ΠΌΠΈΠ»ΠΈΡŽ while (rule != 0){ cin >> rule; // cin.get() Ρ‚ΠΎΡ‚ ΠΆΠ΅ эффСкт ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ° пропускаСт Π²ΠΎΠΎΠ΄ Ρ„Π°ΠΌΠΈΠ»ΠΈΠΈ Π° сразу ΠΏΠ΅Ρ€Π΅Ρ…ΠΎΠ΄ΠΈΡ‚ ΠΊ ΠΈΠΌΠ΅Π½ΠΈ switch (rule){ case 1://add { do { OurSponsors = AddStruct(OurSponsors, sponsorAmount); setData(OurSponsors, sponsorAmount); sponsorAmount++; cout << "ΠŸΡ€ΠΎΠ΄ΠΎΠ»ΠΆΠΈΡ‚ΡŒ Π²Π²ΠΎΠ΄ Π΄Π°Π½Π½Ρ‹Ρ… (1 - Π΄Π°, 0 - Π½Π΅Ρ‚): "; cin >> YesOrNot; cin.get(); } while (YesOrNot != 0); break; } case 2://edit { editData(OurSponsors); break; } case 3://ΠΏΠΎΠΊΠ°Π·Π°Ρ‚ΡŒ { showData(OurSponsors, sponsorAmount); break; } case 4: //Π·Π°Π³Ρ€ΡƒΠ·ΠΈΡ‚ΡŒ { break; } } } delete[] OurSponsors; return 0; } Sponsor* AddStruct(Sponsor* Obj, const int amount) { if (amount == 0) { Obj = new Sponsor[1]; // Π²Ρ‹Π΄Π΅Π»Π΅Π½ΠΈΠ΅ памяти для ΠΏΠ΅Ρ€Π²ΠΎΠΉ структуры } else { Sponsor* tempObj = new Sponsor[amount + 1]; for (int i = 0; i < amount; i++) { tempObj[i] = Obj[i]; // ΠΊΠΎΠΏΠΈΡ€ΡƒΠ΅ΠΌ Π²ΠΎ Π²Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹ΠΉ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ } delete [] Obj; Obj = tempObj; } return Obj; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void setData(Sponsor* Obj, const int amount) { cout << "Ѐамилия: "; cin.getline(Obj[amount].surname, 32); cout << "Имя: "; cin.getline(Obj[amount].name, 32); cout << "Π‘ΡƒΠΌΠΌΠ° поТСртвования: "; cin >> Obj[amount].sum; cin.get(); cout << endl; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void showData(const Sponsor* Obj, const int amount) { system("cls"); cout << "β„– " << "Ѐамилия\t" << "Имя\t" << "Π‘ΡƒΠΌΠΌΠ°\t" << endl; cout << "========================================" << endl; for (int i = 0; i < amount; i++) { cout << i + 1 << " " << Obj[i].surname << '\t' << Obj[i].name << '\t' << Obj[i].sum << endl; } system("pause"); } 

Situation when registering cin or cin.get ()

    1 answer 1

    [Sad and tired] after entering the number with cin >> N , unreadable characters (if there are such) remain in the input buffer until the end of the line let the end of the line itself ...

    If after that you read something not numeric, roughly speaking, you read the empty string ...

    To avoid this, you need to reset the buffer, for example, like this:

     сin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); 

    (see here ).