#include <iostream>
#include <fstream>
#include <climits>
#include <cstring>

char           *
Wczytaj()
{
  char           *wynik = new char[1];
  unsigned        DLwynik = 0;
  while (true)
  {
    char            Bufor[5];
    cin.getline(Bufor, sizeof(Bufor));
    unsigned        DLbufor = strlen(Bufor);
    char           *nowy = new char[DLwynik + DLbufor + 1];
    memcpy(nowy, wynik, DLwynik);
    memcpy(nowy + DLwynik, Bufor, DLbufor);
    delete[] wynik;
    wynik = nowy;
    DLwynik += DLbufor;
    if (DLbufor < cin.gcount())
      break;
    cin.clear();
  }
  wynik[DLwynik] = 0;
  return (wynik);
}

int 
main()
{
  while (true)
  {
    unsigned        X;
    cout << "Podaj X: ";
    cin >> X;
    double          Y;
    cout << "Podaj Y: ";
    cin >> Y;
    cin.ignore(INT_MAX, '\n');
    char           *S;
    cout << "Podaj S: ";
    S = Wczytaj();
    fstream         f;
f.open("liczba.bin", ios: : out | ios: : binary | ios: :trunc);
    f.write((char *)&X, sizeof(X));
    f.write((char *)&Y, sizeof(Y));

    unsigned        DL = strlen(S);
    f.write((char *)&DL, sizeof(DL));
    f.write(S, DL);

    f.close();
    delete[] S;
  }
  return 0;
}

