Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania
Viewing all articles
Browse latest Browse all 65225

Konwersja unsigned char, int na stringa

$
0
0

Cześć, mógłby ktoś mi wytłumaczyć, jak przekonwertować zmienną age (unsigned char) oraz phone_number (unsigned int) na stringa? Mam problem z zapisaniem danych do pliku tekstowego.

 

case 2:
            {
                std::string name, surname;
                unsigned char age;
                unsigned int phone_number;

                std::cout << "Podaj imie: ";
                std::cin >> name;
                std::cout << "Podaj nazwisko: ";
                std::cin >> surname;
                std::cout << "Podaj wiek: ";
                std::cin >> age;
                std::cout << "Podaj numer telefonu: ";
                std::cin >> phone_number;

                std::fstream file;
                file.open("patient.txt", std::ios::app | std::ios::out);
                    if(file.good() == false)
                    {
                        std::cout << "Ten plik nie istnieje - blad.";
                        return 0;
                    }

                file << "\n"<< name << "\n";
                file << surname << "\n";
                file << age << "\n";
                file << phone_number << "\n";

                file.close();

            }

 


Viewing all articles
Browse latest Browse all 65225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>