cpp:isteams
This is an old revision of the document!
Input Streams
Όπως προαναφέρθηκε τα streams εισόδου χρησιμοποιούν τον τελεστη « (stream extraction operator) για την ανάγνωση από το stream. H standard βιβλιοθήκη παρέχει συναρτήσεις υπεφόρτωσης για τους βασικούς τύπους δεδομένων, ενώ δύνεται η δυνατότητα υπερφόρτωσης για όλους τους μη βασικούς τύπους που θα χρειαστεί να κατασκευάσετε στα προγράμματα σας. Το παρακάτω παράδειγμα διαβάσματος από το πληκτρολόγιο (stdin) είναι ενδεικτικό.
- istream_example.cpp
#include <iostream> #include <cstdlib> // for exit() using namespace std; int main() { char c, str[256]; int number; double factor; cin >> c; cout << "Read: " << c << endl; cin >> str; cout << "Read: " << str << endl; cin >> number; cout << "Read: " << number << endl; cin >> factor; cout << "Read: " << factor << endl; }
Για είσόδο hello -1512 1.63
, η έξοδος είναι
Read: h Read: ello Read: -1512 Read: 1.63
cpp/isteams.1557838136.txt.gz · Last modified: 2019/05/14 11:48 (external edit)