Docsity
Docsity

Prepara i tuoi esami
Prepara i tuoi esami

Studia grazie alle numerose risorse presenti su Docsity


Ottieni i punti per scaricare
Ottieni i punti per scaricare

Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium


Guide e consigli
Guide e consigli


Algorithms and Parallel Computing - PARTE 3, Schemi e mappe concettuali di Algoritmi E Programmazione Avanzata

Parte 3 del riassunto del corso di Algorithms and Parallel Computing tenuto dal prof Danilo Ardagna al Politecnico di Milano. File diviso in 4 parti perché troppo pesante. Questo è un riassunto completo e dettagliato degli argomenti fondamentali del corso (voto preso all’esame: 30L)

Tipologia: Schemi e mappe concettuali

2022/2023

In vendita dal 05/02/2023

giulia-ortolani-1
giulia-ortolani-1 🇮🇹

4

(4)

25 documenti

1 / 5

Toggle sidebar

Questa pagina non è visibile nell’anteprima

Non perderti parti importanti!

bg1
pf3
pf4
pf5

Anteprima parziale del testo

Scarica Algorithms and Parallel Computing - PARTE 3 e più Schemi e mappe concettuali in PDF di Algoritmi E Programmazione Avanzata solo su Docsity!

STREAMS &% 1/0 LL file = sequence of bgies. stofed in permanent storage <> neon we can read/write a file if we know its name and its formar Crete È ge) pnt TO READ we musi Know_its name, open.it for reading, read and +tien close it (4ypically impucit : when the stream dojeci S destroged ) ‘o 00 Sent ite name dfatteam = input steam from a file on tetto IFHISEI errori To WRITE. we must name it, open it for writing / creafe it, write and then doit (Aypicaliy implicit : when the Stream cojecr destroged ) n'è open PILE"); St no enter dite nome: “; ofstteam = outpur siteam from a file ) when an fstream objet qpes cur of scope, tne file it is bound to iS aufomaticoli!y. doted READING A FILE : ifstream ist{filename}; NO COPY or ASSIGN FOR LIO OBJECTS: we cannoî have a parameter er sw iyee while(ist >> hour >> temperature) {..} ita Dread functions sho1 do 110. Agricatiy poss and renen EA toe e 11, st ming an XI0. obj changes its se "o me rete ne FILE MODES AND BINARY IO FILE OPEN MODES = ifstream/ofstream open its file for reading | writi if we wont 10 specify a mode : ofstream a sla i alrernatives sto end ping mode. riancare fe to ngi appendi nei. i ios_base: tapp, ios_base:!ate, ios_base::binary, ios_base::in, ios_base: tout, ios_base::trunc in Winary files: we use, ses 10 delie vowes in text dies, we use 3sporonon/ fermination chormcter STRING STRERMS : read/writes fromito a string falher than a file Or a Kegboord/ screen © —> © usaiui fr Smog imo a fred space and ExoGing. dyget Objects cut of 0 sing double str_to_double(string s){ istringstream is{s}; & double d; W2_MOKE a_sitin 10 we_cOn_Fead. fiom è use >> insead of getline() is >> dj pub ind and get() to read individual characters } index starts from O POSITIONING IN A FILESTRENM: * fs.seekg(5); move reading. position to 5 Cine 6% character) — On) for istream | panfr fstream fs{name}; n _ fstream * fs.seekp(1); move writing. poxtion to 1 —* 9n4y for ostream | iostreon althougi, ‘mefe are no distinc fead and write, markers Cihe uurory makes is eta Me porn ont in vi ostringstream is useful wnen we need to build Up our Gutpur a littie AT a time bur do not want 10 print the ourpur unril Later