//============================================================== // "Zmienne" dynamiczne;
// operatory new i delete.
// Operacje In / Out z pomocą strumieni C++ // i alternatywnie
// z pomocą funkcji C. //
// ver data temat autor // 100 2001/10/11 Pierwszy projekt J.Malinowski // 102 2019/08/22 Cleanup JM //============================================================== #include <cstdlib> #include <iostream> using namespace std; //============================================================== int main(int argc, char *argv[])
{
float *X;
X = new float;
cout << "Podaj liczbe: "; cin >> *X; cout << "X= " << *X << endl; printf("Podaj liczbe: "); scanf( "%f", X ); printf("X= %f\n", *X); printf("X= %9.2f\n", *X);
// Istotne! usuwanie struktury dynamicznej; delete X;
//============================================================== double *pX = new double;
printf("Podaj liczbe: "); scanf( "%lf", pX );
printf("X= %f\n", *pX); printf("X= %9.2f\n", *pX);
// Istotne! usuwanie struktury dynamicznej; delete pX;
return 0; }