Programovanie v jazyku C - modularita

Size: px
Start display at page:

Download "Programovanie v jazyku C - modularita"

Transcription

1 CVIČENIE 11/13 (SW2) Programovanie v jazyku C - modularita About vkladanie suborov, modularne programovanie, prikaz make TODO: SOUBOR X STANDARDNÍ VSTUP-VÝSTUP - typická situace: čteme data a podle kontextu budeme pracovat se souborem nebo se standardním vstupem /výstupem knihovny na to myslely <stdio.h>... definice FILE FILE* stdin; FILE* stdout; tedy standardní vstup a výstup jsou soubory - jsou inicializovány před spuštěním main - kam jsou tyto soubory namířeny, závisí na OS - stdin a stdout se neotvírají explicitně, ale dělají to knihovny getchar... getc(stdin) printf... fprintf(stdout,...) VOLÁNÍ PROGRAMů - historické ale stále se používá zarovnej.exe [-l][-r][-c][-w80][-fi soubor] [-fo soubor] - rozšířená syntaxe -jmeno=hodnota zarovnej.exe --align=right/left --weight=80 --filein=in.txt --fileout=out.txt Priklad: napište program na zarovnávání souboru doprava nebo doleva podle následujících parametrů zarovnej.exe --align=right/left --weight=80 --filein=in.txt --fileout=out.txt Když některý z parametrů není uveden, pak uvažujte následující defaultní hodnoty: weight filein... standardní vstup fileout... standardní výstup align... doleva

2 Basic knowledge prikaz include sa pouziva na vkladanie suborov. takyto vlozeny subor bude vlozeny presne na miesto, kde sa nachadza prikaz include. su mozne dve varianty pouzitia: 1. #include <nazov_suboru> - takyto hlavickovy subor sa hlada v systemovom adresari (hlada medzi standardnymi hlavickovymi subormi) 2. #include "nazov_suboru" - takyto hlavickovy subor sa hlada v aktualnom adresari. jedna sa o nami vytvoreny hlavickovy subor. vkladanie hlavickovych suborov ma za nasledok: rozdelenie programu na mensie casti (celky), ktore spolu logicky suvisia samotny kod bude citatelnejsi a prehladnejsi zmena, ktora sa urobi v jednom hlavickovom subore, ovplyvni vsetky casti programu (vsetky moduly), kde sa tento hlavickovy subor vklada hlavickovy subor obsahuje: definicie konstant, makier a makier preprocesora prototypy funkcii deklaracie/definicie premennych struktury, uzivatelske typy kazdy hlavickovy subor/modul moze byt do celkoveho programu vlozeny len raz! preto treba davat pozor na vnaranie a niekolkonasobnemu nahraniu toho isteho suboru ku kazdemu hlavickovemu suboru (*.h) existuje *.c subor. nazov sa lisi iba priponou. jednoduchy priklad moze vyzerat takto: modul.h void vypis( char *text ); modul.c void vypis( char *text ) printf( "mam vypisat: %s\n", text ); main.c #include <stdio.h>

3 #include "modul.h" int main( void ) vypis( "battlestar galactica" ); getchar(); return( 0 ); vysledny program prelozime nasledovne: $ gcc main.c modul.c v dlhsich programoch sa moze stat, ze vzniknu zavislosti na jednotlivych moduloch. napriklad: majme niekolko.c programov: main.c, modul.c, funkcie.c a modul2.c. main.c vola funkcie vsetkych modulov a moduly su na sebe tiez zavisle. kazdy subor potom moze zacat nasledovnymi riadkami: #include "modul.h" #include "modul2.h" #include "funkcie.h" co ma za nasledok, ze sa to nebude prekladacu pacit. problem sa da vyriesit tak, ze sa dopredu stanovi poradie preberania a vykonavania jednotlivych funkcii v moduloch a poradie ich vkladania. taketo riesenie sak v praxi nejde velmi casto previest. preto sa zabezpecuje, ze sa dany modul vlozi do programu iba raz. #ifndef _FUNKCIE_H #define _FUNKCIE_H void vypis( char *text ); #endif takto sa skutocne v praxi programuje - modul sa vlozi iba vtedy, pokial nie je definovane makro s charakteristickym menom. inak vlozi preprocesor iba niekolko prazdnych riadkov ;) pri modularnom programovani je dolezita otazka zivotnosti a viditelnosti premennych, funkcii,... v ostatnych moduloch, resp. v celom programe. globalne premenne z ineho suboru sa spristupnuju pomocou klucoveho slova extern. pokial v jednom subore definujeme: int pocitadlo; mozeme tuto premennu pouzivat z druheho suboru, pokial v nom deklarujeme: extern int pocitadlo;

4 niekedy je potrebne, aby nejaka premenna sa inicializovala iba raz a vzdy pri volani instancie funkcie, v ktorej bola deklarovana, sa pouzila uz static make v praxi sa modularita programov neriesi sposobom uvedenym vyssie - vsetky.c subory sa prelozia sucasne v ramci vyslednej kompilacie. preklad vacsich programov moze byt velmi casovo narocny. preto sa vyuziva sposob oddelenho a ciastkoveho prekladu, kde mozeme vyuzit medzivysledky minuleho prekladu. $ gcc subor1.c -c $ gcc subor2.c -c $ gcc suborn.c -c $ gcc subor1.o subor2.o subor3.o -o program prvymi prikazmi sa prevedie oddeleny preklad jednotlivych suborov a vytvoria sa objektove subory (*.o). v poslednom kroku objektove subory zlinkujeme do vysledneho suboru. pokial teda pri ladeni dojde k zmene v subore subor1.c, vykoname nasledovne: $ gcc subor1.c -c $ gcc subor1.o subor2.o suborn.o -o program tym doslo k prekompilovaniu iba suboru subor1.c a zvysok bol pouzity z predchadzajucej kompilacie. cely tento proces automatizuje nastroj make. prikaz sleduje zmeny v suboroch a podla konfiguracie suboru Makefile, ktory sa pouziva na riadenie prekladu, vykona potrebne operacie. nemusi vykonavat len akcie pre samotny preklad - moze vykonat lubovolny prikaz operacneho systemu. priklad Makefile-u pre nas predchadzajuci priklad by mohol byt nasledovny: program: subor1.o subor2.o suborn.o gcc subor1.o subor2.o suborn.o -o program subor1.o: subor1.c gcc subor1.c -c subor2.o: subor2.c gcc subor2.c -c suborn.o: suborn.c gcc suborn.c -c clean: rm -rf *.o program sputenie prekladu sa vykonava prikazom:

5 $ make syntax Makefile-u je nasledovna: ciel: zavislost1 zavislost2... [tabulator]akcia pozor na skutocnost, ze kazda akcia zacina tabulatorom! pokial tam nebude, make bude hlasit chybu. pokial je make volany bez argumentov, je prelozeny cely program. je taktiez mozne spustit len niektoru cast prekladu a to zadanim ciela ako argumentu prikazu make, napriklad: $ make clean tym sa vykona len tak cast Makefile-u, ktora je uvedena za castou clean. ako na modularitu v dev-c++ dev-c++ pouziva na modularne programovanie projekty. takze treba vytvorit projekt a vsetky moduly vlozit do neho: 1. subor->novy->projekt vyberieme: console application, a v nastaveniach projektu napiseme jeho nazov a zaskrtneme c projekt a potvrdime ok 3. zvolime miesto, kam sa ma dany projekt ulozit na disku 4. momentalne je vytovoreny subor main.c pomocou ikonky zdrojovy kod (ctrl+n) alebo pomocou menu subor->novy->zdrojovy kod (ctrl+n) je mozne pridavat do projektu dalsie subory 5. vysledok sa preklada podobne ako doteraz - pomocou klavesy f9 (aj spusti) a program si sam vytvara Makefile a robi vsetko ostatne za nas 6. samotny Makefile je potom ulozeny v tom adresari, v ktorom je ulozeny dany projekt a vola sa Makefile.win Examples Ex. 1: napiste program, ktory vypise dany subor na obrazovku. vytvorte dva subory podla nasledovnej predlohy a citanie realizujte pomocou funkcie citaj, ktora zo suboru vrati vzdy iba jeden znak. program prelozte pomocou prikazu gcc. main.c #include <stdio.h> #include "citaj.h" int main( int argc, char* argv[] )

6 FILE *fp; // testneme, ci bol program spravne spusteny if( argc!= 2 ) printf( "syntax: %s nazov_suboru\n", argv[0] ); exit(1); // ak bol zadany aj nazov suboru, tak ho skusime otvorit fp = fopen( argv[1], "r" ); // co ak taky subor nie je? tak skoncime if(!fp ) printf( "subor %s sa nepodarilo otvorit\n", argv[1] ); exit(1); // tu bude nasledovat hlavna cast programu while(!feof(fp) ) // na tomto mieste treba vyuzit funkciu citaj z modulu citaj.h printf( "bye\n" ); getchar(); getchar(); return( 0 ); citaj.h int citaj_znak( FILE *fp ); citaj.c #include <stdio.h> int citaj_znak( FILE *fp ) // implementacia samotnej funkcie na nacitanie znaku zo suboru Ex. 2: ku programu zostavte Makefile na zjednodusenie prekladu. vlozte do neho aj moznost clean na zmazanie object file-ov a moznost all na prelozenie celeho programu. Ex. 3: modifikujte program tak, ze zmenite funkciu citaj na funkciu s nasledovnym prototypom: long citaj( FILE *fp, int *p_c ), kde: funkcia vracia nacitany znak vo svojom druhom argumente navratovu hodnotu funkcie tvori celkovy pocet volani danej funkcie (vyuzitie lokalnej static premennej)

Databázové systémy. SQL Window functions

Databázové systémy. SQL Window functions Databázové systémy SQL Window functions Scores Tabuľka s bodmi pre jednotlivých študentov id, name, score Chceme ku každému doplniť rozdiel voči priemeru 2 Demo data SELECT * FROM scores ORDER BY score

More information

VYLEPŠOVANIE KONCEPTU TRIEDY

VYLEPŠOVANIE KONCEPTU TRIEDY VYLEPŠOVANIE KONCEPTU TRIEDY Typy tried class - definuje premenné a metódy (funkcie). Ak nie je špecifikovaná inak, viditeľnosť členov je private. struct - definuje premenné a metódy (funkcie). Ak nie

More information

kucharka exportu pro 9FFFIMU

kucharka exportu pro 9FFFIMU požiadavky na export kodek : Xvid 1.2.1 stable (MPEG-4 ASP) // výnimočne MPEG-2 bitrate : max. 10 Mbps pixely : štvorcové (Square pixels) rozlíšenie : 1920x1080, 768x432 pre 16:9 // výnimočne 1440x1080,

More information

Databázy (1) Prednáška 11. Alexander Šimko

Databázy (1) Prednáška 11. Alexander Šimko Databázy (1) Prednáška 11 Alexander Šimko simko@fmph.uniba.sk Contents I Aktualizovanie štruktúry databázy Section 1 Aktualizovanie štruktúry databázy Aktualizácia štruktúry databázy Štruktúra databázy

More information

Spájanie tabuliek. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Spájanie tabuliek. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) Spájanie tabuliek Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) 2011-2016 Úvod pri normalizácii rozdeľujeme databázu na viacero tabuliek prepojených cudzími kľúčmi SQL umožňuje tabuľky opäť spojiť

More information

Poradové a agregačné window funkcie. ROLLUP a CUBE

Poradové a agregačné window funkcie. ROLLUP a CUBE Poradové a agregačné window funkcie. ROLLUP a CUBE 1) Poradové a agregačné window funkcie 2) Extrémy pomocou DENSE_RANK(), TOP() - Príklady 3) Spriemernené poradia 4) Kumulatívne súčty 5) Group By a Datepart,

More information

Basic and Practice in Programming Lab 10

Basic and Practice in Programming Lab 10 Basic and Practice in Programming Lab 10 File (1/4) File management in C language FILE data type (strictly, data structure in C library) Three operational modes Read/Write/Append fopen A library function

More information

Aplikačný dizajn manuál

Aplikačný dizajn manuál Aplikačný dizajn manuál Úvod Aplikačný dizajn manuál je súbor pravidiel vizuálnej komunikácie. Dodržiavaním jednotných štandardov, aplikácií loga, písma a farieb pri prezentácii sa vytvára jednotný dizajn,

More information

Copyright 2016 by Martin Krug. All rights reserved.

Copyright 2016 by Martin Krug. All rights reserved. MS Managed Service Copyright 2016 by Martin Krug. All rights reserved. Reproduction, or translation of materials without the author's written permission is prohibited. No content may be reproduced without

More information

REPORT DESIGNER 1 VYTVORENIE A ÚPRAVA FORMULÁRA. úprava formulárov v Money S4 / Money S Vytvorenie formulára

REPORT DESIGNER 1 VYTVORENIE A ÚPRAVA FORMULÁRA. úprava formulárov v Money S4 / Money S Vytvorenie formulára REPORT DESIGNER úprava formulárov v Money S4 / Money S5 Informačný systém Money S4/S5 umožňuje upraviť tlačové zostavy tak, aby plne vyhovovali potrebám používateľa. Na úpravu tlačových zostáv slúži doplnkový

More information

Programovanie v jazyku Python. Michal Kvasnica

Programovanie v jazyku Python. Michal Kvasnica Programovanie v jazyku Python Michal Kvasnica Organizačné detaily Prednášky aj cvičenia v 638 Povinná účasť na cvičeniach Hodnotenie: priebežné odovzdávanie zadaní (40% známky) záverečný projekt na skúške

More information

Constraint satisfaction problems (problémy s obmedzujúcimi podmienkami)

Constraint satisfaction problems (problémy s obmedzujúcimi podmienkami) I2AI: Lecture 04 Constraint satisfaction problems (problémy s obmedzujúcimi podmienkami) Lubica Benuskova Reading: AIMA 3 rd ed. chap. 6 ending with 6.3.2 1 Constraint satisfaction problems (CSP) We w

More information

1 Komplexný príklad využitia OOP

1 Komplexný príklad využitia OOP 1 Komplexný príklad využitia OOP Najčastejším využitím webových aplikácií je komunikácia s databázovým systémom. Komplexný príklad je preto orientovaný práve do tejto oblasti. Od verzie PHP 5 je jeho domovskou

More information

Testovanie bieleho šumu

Testovanie bieleho šumu Beáta Stehlíková FMFI UK Bratislava Opakovanie z prednášky Vygenerujeme dáta Vygenerujeme dáta: N

More information

File IO and command line input CSE 2451

File IO and command line input CSE 2451 File IO and command line input CSE 2451 File functions Open/Close files fopen() open a stream for a file fclose() closes a stream One character at a time: fgetc() similar to getchar() fputc() similar to

More information

Triedy v C++ 1. Úvod do tried

Triedy v C++ 1. Úvod do tried 1. Úvod do tried Používanie nového dátového typu ktorý budeme oht class trieda nás dovedie k využívaniu objektových vlastností jazyka C++. Tento nový typ programov OOP objektovo orientované programovanie

More information

File Access. FILE * fopen(const char *name, const char * mode);

File Access. FILE * fopen(const char *name, const char * mode); File Access, K&R 7.5 Dealing with named files is surprisingly similar to dealing with stdin and stdout. Start by declaring a "file pointer": FILE *fp; /* See Appendix B1.1, pg. 242 */ header

More information

LL LED svietidlá na osvetlenie športovísk. MMXIII-X LEADER LIGHT s.r.o. Všetky práva vyhradené. Uvedené dáta podliehajú zmenám.

LL LED svietidlá na osvetlenie športovísk. MMXIII-X LEADER LIGHT s.r.o. Všetky práva vyhradené. Uvedené dáta podliehajú zmenám. LL LED svietidlá na osvetlenie športovísk MMXIII-X LEADER LIGHT s.r.o. Všetky práva vyhradené. Uvedené dáta podliehajú zmenám. LL SPORT LL SPORT je sofistikované vysoko výkonné LED svietidlo špeciálne

More information

APT Session 4: C. Software Development Team Laurence Tratt. 1 / 14

APT Session 4: C. Software Development Team Laurence Tratt. 1 / 14 APT Session 4: C Laurence Tratt Software Development Team 2017-11-10 1 / 14 http://soft-dev.org/ What to expect from this session 1 C. 2 / 14 http://soft-dev.org/ Prerequisites 1 Install either GCC or

More information

Registrácia účtu Hik-Connect

Registrácia účtu Hik-Connect Registrácia účtu Hik-Connect Tento návod popisuje postup registrácie účtu služby Hik-Connect prostredníctvom mobilnej aplikácie a webového rozhrania na stránke www.hik-connect.comg contents in this document

More information

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems Deep C Multifile projects Getting it running Data types Typecasting Memory management Pointers Fabián E. Bustamante, Fall 2004 Multifile Projects Give your project a structure Modularized design Reuse

More information

Databázy (1) Prednáška 08. Alexander Šimko

Databázy (1) Prednáška 08. Alexander Šimko Databázy (1) Prednáška 08 Alexander Šimko simko@fmph.uniba.sk Contents I Subqueries (poddopyty) konštrukcia WITH Section 1 Subqueries (poddopyty) Subquery (poddopyt) Použitie SELECTu na mieste, kde sme

More information

Content. Input Output Devices File access Function of File I/O Redirection Command-line arguments

Content. Input Output Devices File access Function of File I/O Redirection Command-line arguments File I/O Content Input Output Devices File access Function of File I/O Redirection Command-line arguments UNIX and C language C is a general-purpose, high-level language that was originally developed by

More information

UNIVERZITA KOMENSKÉHO V BRATISLAVE FAKULTA MATEMATIKY, FYZIKY A INFORMATIKY VÝUKOVÁ WEBOVÁ APLIKÁCIA NA PROGRAMOVANIE GPU.

UNIVERZITA KOMENSKÉHO V BRATISLAVE FAKULTA MATEMATIKY, FYZIKY A INFORMATIKY VÝUKOVÁ WEBOVÁ APLIKÁCIA NA PROGRAMOVANIE GPU. UNIVERZITA KOMENSKÉHO V BRATISLAVE FAKULTA MATEMATIKY, FYZIKY A INFORMATIKY VÝUKOVÁ WEBOVÁ APLIKÁCIA NA PROGRAMOVANIE GPU Diplomová práca 2017 Bc. Denis Spišák UNIVERZITA KOMENSKÉHO V BRATISLAVE FAKULTA

More information

CSCI 2132 Final Exam Solutions

CSCI 2132 Final Exam Solutions Faculty of Computer Science 1 CSCI 2132 Final Exam Solutions Term: Fall 2018 (Sep4-Dec4) 1. (12 points) True-false questions. 2 points each. No justification necessary, but it may be helpful if the question

More information

Main differences with Java

Main differences with Java Signals, Instruments, and Systems W2 C Programming (continued) C Main differences with Java C is NOT object oriented. (C++ is OO) C code is directly translated into binary that can be directly executed

More information

Databázy (2) Prednáška 08. Alexander Šimko

Databázy (2) Prednáška 08. Alexander Šimko Databázy (2) Prednáška 08 Alexander Šimko simko@fmph.uniba.sk Contents I Funkcie Zložené typy PL/pgSQL Agregačné funkcie Funkcie Section 1 Funkcie Funkcie PostgreSQL umožňuje vytvoriť si vlastné databázové

More information

Rýchlosť Mbit/s (download/upload) 15 Mbit / 1 Mbit. 50 Mbit / 8 Mbit. 80 Mbit / 10 Mbit. 10 Mbit / 1 Mbit. 12 Mbit / 2 Mbit.

Rýchlosť Mbit/s (download/upload) 15 Mbit / 1 Mbit. 50 Mbit / 8 Mbit. 80 Mbit / 10 Mbit. 10 Mbit / 1 Mbit. 12 Mbit / 2 Mbit. Fiber 5 Mbit ** 5 Mbit / Mbit 5,90 Fiber 50 Mbit * 50 Mbit / 8 Mbit 9,90 Fiber 80 Mbit * 80 Mbit / Mbit 5,90 Mini Mbit* Mbit / Mbit 9,90 Klasik 2 Mbit* 2 Mbit / 2 Mbit Standard 8 Mbit* 8 Mbit / 3Mbit Expert

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

Personal SE. Functions, Arrays, Strings & Command Line Arguments

Personal SE. Functions, Arrays, Strings & Command Line Arguments Personal SE Functions, Arrays, Strings & Command Line Arguments Functions in C Syntax like Java methods but w/o public, abstract, etc. As in Java, all arguments (well, most arguments) are passed by value.

More information

Software Development With Emacs: The Edit-Compile-Debug Cycle

Software Development With Emacs: The Edit-Compile-Debug Cycle Software Development With Emacs: The Edit-Compile-Debug Cycle Luis Fernandes Department of Electrical and Computer Engineering Ryerson Polytechnic University August 8, 2017 The Emacs editor permits the

More information

MS Exchange 2010 Prechod Ing. Peter Záhradník

MS Exchange 2010 Prechod Ing. Peter Záhradník MS Exchange 2010 Prechod Ing. Peter Záhradník Gratex Support Center support@gratex.com Exchange 2010 o com to bude? Tato prezentacia bude pre ludi co uvazuju nad prechodom na novy Exchange zopar otazok

More information

Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE. Advanced Operating Systems A.A Exam date: 28 June 2016

Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE. Advanced Operating Systems A.A Exam date: 28 June 2016 Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE Advanced Operating Systems A.A. 2015-2016 Exam date: 28 June 2016 Prof. William FORNACIARI Surname (readable)... Matr... Name (readable)...

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

Recipient Configuration. Štefan Pataky MCP, MCTS, MCITP

Recipient Configuration. Štefan Pataky MCP, MCTS, MCITP Recipient Configuration Štefan Pataky MCP, MCTS, MCITP Agenda Mailbox Mail Contact Distribution Groups Disconnected Mailbox Mailbox (vytvorenie nového účtu) Exchange Management Console New User Exchange

More information

Obrázok č. 1 Byte. Obrázok č. 2 Slovo

Obrázok č. 1 Byte. Obrázok č. 2 Slovo C++ pod lupou Nie som ortodoxným prívržencom nijakého dnes používaného jazyka, poznám ich už riadnu kôpku, ale najbližšie mám práve k C++. Prečo, o tom by sa dalo diskutovať donekonečna, nie je to však

More information

Friday, September 16, Lab Notes. Command line arguments More pre-processor options Programs: Finish Program 1, begin Program 2 due next week

Friday, September 16, Lab Notes. Command line arguments More pre-processor options Programs: Finish Program 1, begin Program 2 due next week Friday, September 16, 2016 Lab Notes Topics for today Redirection of input and output Command line arguments More pre-processor options Programs: Finish Program 1, begin Program 2 due next week 1. Redirection

More information

C for Engineers and Scientists: An Interpretive Approach. Chapter 14: File Processing

C for Engineers and Scientists: An Interpretive Approach. Chapter 14: File Processing Chapter 14: File Processing Files and Streams C views each file simply as a sequential stream of bytes. It ends as if there is an end-of-file marker. The data structure FILE, defined in stdio.h, stores

More information

C programming basics T3-1 -

C programming basics T3-1 - C programming basics T3-1 - Outline 1. Introduction 2. Basic concepts 3. Functions 4. Data types 5. Control structures 6. Arrays and pointers 7. File management T3-2 - 3.1: Introduction T3-3 - Review of

More information

PV030 Textual Information Systems

PV030 Textual Information Systems PV030 Textual Information Systems Petr Sojka Faculty of Informatics Masaryk University, Brno Spring 2010 Đ Ý Petr Sojka PV030 Textual Information Systems Osnova(Týden šestý) ü Vyhledávání s předzpracováním

More information

(T) x. Casts. A cast converts the value held in variable x to type T

(T) x. Casts. A cast converts the value held in variable x to type T Several New Things 2 s complement representation of negative integers The data size flag in the conversion specification of printf Recast of &n to unsigned long to get the address 2 3 Casts (T) x A cast

More information

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function Grade: / 20 Lab Exam 1 D500 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return 0? Answer: Anything that is not a floating point number such as 4.567 or

More information

Recitation 2/18/2012

Recitation 2/18/2012 15-213 Recitation 2/18/2012 Announcements Buflab due tomorrow Cachelab out tomorrow Any questions? Outline Cachelab preview Useful C functions for cachelab Cachelab Part 1: you have to create a cache simulator

More information

Textový formát na zasielanie údajov podľa 27 ods. 2 písm. f) zákona

Textový formát na zasielanie údajov podľa 27 ods. 2 písm. f) zákona Popis textového formátu a xsd schémy na zasielanie údajov podľa 27 ods. 2 písm. f) zákona (formu na zaslanie údajov si zvolí odosielateľ údajov) Textový formát na zasielanie údajov podľa 27 ods. 2 písm.

More information

MATLAB EXCEL BUILDER A NÁVRH PID REGULÁTOROV PRE PROSTREDIE MS EXCEL

MATLAB EXCEL BUILDER A NÁVRH PID REGULÁTOROV PRE PROSTREDIE MS EXCEL MATLAB EXCEL BUILDER A NÁVRH PID REGULÁTOROV PRE PROSTREDIE MS EXCEL Martin Foltin, Ivan Sekaj Fakulta elektrotechniky a informatiky, Slovenská Technická Univerzita, Ilkovičova 3, 812 19 Bratislava, Slovenská

More information

CSCI-243 Exam 2 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCI-243 Exam 2 Review February 22, 2015 Presented by the RIT Computer Science Community CSCI-43 Exam Review February, 01 Presented by the RIT Computer Science Community http://csc.cs.rit.edu C Preprocessor 1. Consider the following program: 1 # include 3 # ifdef WINDOWS 4 # include

More information

COMP 2355 Introduction to Systems Programming

COMP 2355 Introduction to Systems Programming COMP 2355 Introduction to Systems Programming Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 Functions Similar to (static) methods in Java without the class: int f(int a, int

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 14

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 14 BIL 104E Introduction to Scientific and Engineering Computing Lecture 14 Because each C program starts at its main() function, information is usually passed to the main() function via command-line arguments.

More information

are all acceptable. With the right compiler flags, Java/C++ style comments are also acceptable.

are all acceptable. With the right compiler flags, Java/C++ style comments are also acceptable. CMPS 12M Introduction to Data Structures Lab Lab Assignment 3 The purpose of this lab assignment is to introduce the C programming language, including standard input-output functions, command line arguments,

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 2: Hello World! Cristina Nita-Rotaru Lecture 2/ Fall 2013 1 Introducing C High-level programming language Developed between 1969 and 1973 by Dennis Ritchie at the Bell Labs

More information

D.Signer prostriedok pre vytváranie zaručeného elektronického podpisu. Inštalačná príručka

D.Signer prostriedok pre vytváranie zaručeného elektronického podpisu. Inštalačná príručka D.Signer prostriedok pre vytváranie zaručeného elektronického podpisu Inštalačná príručka Obsah 1 Predpoklady pre inštaláciu D.Signer... 3 1.1 Inštalácia.NET Framework... 3 1.1.1 Windows 8, 8.1... 4 1.1.2

More information

Kurt Schmidt. October 30, 2018

Kurt Schmidt. October 30, 2018 to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed

More information

Friday, February 10, Lab Notes

Friday, February 10, Lab Notes Friday, February 10, 2017 Lab Notes Topics for today Structures in C Redirection of input and output in a Unix-like environment Command line arguments More pre-processor options Programs: Finish Program

More information

Programming & Data Structure

Programming & Data Structure File Handling Programming & Data Structure CS 11002 Partha Bhowmick http://cse.iitkgp.ac.in/ pb CSE Department IIT Kharagpur Spring 2012-2013 File File Handling File R&W argc & argv (1) A file is a named

More information

Anycast. Ľubor Jurena CEO Michal Kolárik System Administrator

Anycast. Ľubor Jurena CEO Michal Kolárik System Administrator Anycast Ľubor Jurena CEO jurena@skhosting.eu Michal Kolárik System Administrator kolarik@skhosting.eu O nás Registrátor Webhosting Serverové riešenia Správa infraštruktúry Všetko sa dá :-) Index Čo je

More information

Binghamton University. CS-211 Fall Input and Output. Streams and Stream IO

Binghamton University. CS-211 Fall Input and Output. Streams and Stream IO Input and Output Streams and Stream IO 1 Standard Input and Output Need: #include Large list of input and output functions to: Read and write from a stream Open a file and make a stream Close

More information

8. Characters, Strings and Files

8. Characters, Strings and Files REGZ9280: Global Education Short Course - Engineering 8. Characters, Strings and Files Reading: Moffat, Chapter 7, 11 REGZ9280 14s2 8. Characters and Arrays 1 ASCII The ASCII table gives a correspondence

More information

TYPY, KONŠTANTY, PROCEDÚRY A FUNKCIE PRE PRÁCU S POĽOM

TYPY, KONŠTANTY, PROCEDÚRY A FUNKCIE PRE PRÁCU S POĽOM TYPY, KONŠTANTY, PROCEDÚRY A FUNKCIE PRE PRÁCU S POĽOM Doposiaľ sme si ukázali základné štruktúry a jednotky jazyka. Pracovali sme s premennými rôznych typov ako aj s konštantnými hodnotami. Používali

More information

CS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files

CS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files CS113: Lecture 7 Topics: The C Preprocessor I/O, Streams, Files 1 Remember the name: Pre-processor Most commonly used features: #include, #define. Think of the preprocessor as processing the file so as

More information

Computer Programming. The greatest gift you can give another is the purity of your attention. Richard Moss

Computer Programming. The greatest gift you can give another is the purity of your attention. Richard Moss Computer Programming The greatest gift you can give another is the purity of your attention. Richard Moss Outline Modular programming Modularity Header file Code file Debugging Hints Examples T.U. Cluj-Napoca

More information

Mesačná kontrolná správa

Mesačná kontrolná správa Mesačná kontrolná správa Štrukturálna štúdia dec.16 nov.16 okt.16 sep.16 aug.16 júl.16 jún.16 máj.16 apr.16 mar.16 feb.16 jan.16 Internetová populácia SR 12+ 3 728 988 3 718 495 3 718 802 3 711 581 3 700

More information

System calls and assembler

System calls and assembler System calls and assembler Michal Sojka sojkam1@fel.cvut.cz ČVUT, FEL License: CC-BY-SA 4.0 System calls (repetition from lectures) A way for normal applications to invoke operating system (OS) kernel's

More information

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2 Compiling a C program CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Example of a small program Makefile Define Variables Compilation options Conclusion Berner Fachhochschule Haute

More information

CS Basics 15) Compiling a C prog.

CS Basics 15) Compiling a C prog. CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 Compiling a C program Example of a small

More information

Accessing Files in C. Professor Hugh C. Lauer CS-2303, System Programming Concepts

Accessing Files in C. Professor Hugh C. Lauer CS-2303, System Programming Concepts Accessing Files in C Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

More information

Goals of this Lecture

Goals of this Lecture I/O Management 1 Goals of this Lecture Help you to learn about: The Unix stream concept Standard C I/O functions Unix system-level functions for I/O How the standard C I/O functions use the Unix system-level

More information

Topic 8: I/O. Reading: Chapter 7 in Kernighan & Ritchie more details in Appendix B (optional) even more details in GNU C Library manual (optional)

Topic 8: I/O. Reading: Chapter 7 in Kernighan & Ritchie more details in Appendix B (optional) even more details in GNU C Library manual (optional) Topic 8: I/O Reading: Chapter 7 in Kernighan & Ritchie more details in Appendix B (optional) even more details in GNU C Library manual (optional) No C language primitives for I/O; all done via function

More information

Microsoft Azure platforma pre Cloud Computing. Juraj Šitina, Microsoft Slovakia

Microsoft Azure platforma pre Cloud Computing. Juraj Šitina, Microsoft Slovakia Microsoft Azure platforma pre Cloud Computing Juraj Šitina, Microsoft Slovakia m Agenda Cloud Computing Pohľad Microsoftu Predstavujeme platformu Microsoft Azure Benefity Cloud Computingu Microsoft je

More information

Jazyk SQL. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Jazyk SQL. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) Jazyk SQL Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) 2011-2016 Jazyk SQL - Structured Query Language SQL je počítačový jazyk určený na komunikáciu s relačným SRBD neprocedurálny (deklaratívny) jazyk

More information

I/O Management! Goals of this Lecture!

I/O Management! Goals of this Lecture! I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix

More information

UNIT-V CONSOLE I/O. This section examines in detail the console I/O functions.

UNIT-V CONSOLE I/O. This section examines in detail the console I/O functions. UNIT-V Unit-5 File Streams Formatted I/O Preprocessor Directives Printf Scanf A file represents a sequence of bytes on the disk where a group of related data is stored. File is created for permanent storage

More information

I/O Management! Goals of this Lecture!

I/O Management! Goals of this Lecture! I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix

More information

Mesačná kontrolná správa

Mesačná kontrolná správa Mesačná kontrolná správa Štrukturálna štúdia mar.18 feb.18 jan.18 dec.17 nov.17 okt.17 sep.17 aug.17 júl.17 jún.17 máj.17 apr.17 mar.17 Internetová populácia SR 12+ 3 904 509 3 802 048 3 870 654 3 830

More information

FACULTY OF MECHANICAL ENGINEERING INSTITUTE OF SOLID MECHANICS, MECHATRONICS AND BIOMECHANICS

FACULTY OF MECHANICAL ENGINEERING INSTITUTE OF SOLID MECHANICS, MECHATRONICS AND BIOMECHANICS VYSOKÉ UČENÍ TECHNICKÉ V BRNĚ BRNO UNIVERSITY OF TECHNOLOGY FAKULTA STROJNÍHO INŽENÝRSTVÍ ÚSTAV MECHANIKY TĚLES, MECHATRONIKY A BIOMECHANIKY FACULTY OF MECHANICAL ENGINEERING INSTITUTE OF SOLID MECHANICS,

More information

Cvičenie 1-2 Concept: Locating Controls, Functions, and VIs

Cvičenie 1-2 Concept: Locating Controls, Functions, and VIs Cvičenie 1-2 Concept: Locating Controls, Functions, and VIs 1. Open a blank LabVIEW project. Click the Create Project button in the LabVIEW Getting Started window and then click Blank Project. Click Finish.

More information

PRACOVNÝ ZOŠIT Z PROGRAMOVANIA 2

PRACOVNÝ ZOŠIT Z PROGRAMOVANIA 2 PRACOVNÝ ZOŠIT Z PROGRAMOVANIA 2 Ing. Igor Marko, 2011 PODPROGRAMY V PASCALE DEFINÍCIA, GLOBÁLNE A LOKÁLNE PREMENNÉ Podprogram v programovacom jazyku je postupnosť príkazov vystupujúcich pod jedným názvom,

More information

Základná(umelecká(škola(Jána(Albrechta Topoľčianska(15

Základná(umelecká(škola(Jána(Albrechta Topoľčianska(15 Základná(umelecká(škola(Jána(Albrechta Topoľčianska(15 851(01(Bra@slava Titl.: Ján(Hrčka Bohrova(11 851(01(Bra@slava V(Bra@slave(21.11.2013 Vec:(Odpoveď(na(informácie(ohľadom(mandátnej(zmluvy(na(základe(Zákona(č.(211/2000(Zb.

More information

File Handling. Reference:

File Handling. Reference: File Handling Reference: http://www.tutorialspoint.com/c_standard_library/ Array argument return int * getrandom( ) static int r[10]; int i; /* set the seed */ srand( (unsigned)time( NULL ) ); for ( i

More information

Desatinné čísla #1a. Decimal numbers #1b. How much larger is 21,8 than 1,8? Desatinné čísla #2a. Decimal numbers #2b. 14 divided by 0,5 equals...

Desatinné čísla #1a. Decimal numbers #1b. How much larger is 21,8 than 1,8? Desatinné čísla #2a. Decimal numbers #2b. 14 divided by 0,5 equals... Desatinné čísla #1a Mravec išiel 5,5 cm presne na sever, potom 3,4 cm na východ, 1,8 cm na juh, 14,3 cm na západ, 1,3 cm na sever a 10,9 cm na východ. Najmenej koľko cm musí teraz prejsť, aby sa dostal

More information

Standard File Pointers

Standard File Pointers 1 Programming in C Standard File Pointers Assigned to console unless redirected Standard input = stdin Used by scan function Can be redirected: cmd < input-file Standard output = stdout Used by printf

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

Lab 2: More Advanced C

Lab 2: More Advanced C Lab 2: More Advanced C CIS*2520 Data Structures (S08) TA: El Sayed Mahmoud This presentation is created by many TAs of previous years and updated to satisfy the requirements of the course in this semester.

More information

Lecture 07 Debugging Programs with GDB

Lecture 07 Debugging Programs with GDB Lecture 07 Debugging Programs with GDB In this lecture What is debugging Most Common Type of errors Process of debugging Examples Further readings Exercises What is Debugging Debugging is the process of

More information

Final CSE 131B Spring 2004

Final CSE 131B Spring 2004 Login name Signature Name Student ID Final CSE 131B Spring 2004 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 (25 points) (24 points) (32 points) (24 points) (28 points) (26 points) (22 points)

More information

CSC 2405: Computer Systems II

CSC 2405: Computer Systems II CSC 2405: Computer Systems II Program Execution Environment Execution Environment The main func*on is the entry point for C program execu*on int main( int argc, char * argv[]); The linker (called by the

More information

CSE 333 Lecture 7 - final C details

CSE 333 Lecture 7 - final C details CSE 333 Lecture 7 - final C details Steve Gribble Department of Computer Science & Engineering University of Washington Today s topics: - a few final C details header guards and other preprocessor tricks

More information

25.2 Opening and Closing a File

25.2 Opening and Closing a File Lecture 32 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 32: Dynamically Allocated Arrays 26-Nov-2018 Location: Chemistry 125 Time: 12:35 13:25 Instructor:

More information

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function CMPT 127 Spring 2019 Grade: / 20 First name: Last name: Student Number: Lab Exam 1 D400 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return -1? Answer:

More information

Programming in C. Session 8. Seema Sirpal Delhi University Computer Centre

Programming in C. Session 8. Seema Sirpal Delhi University Computer Centre Programming in C Session 8 Seema Sirpal Delhi University Computer Centre File I/O & Command Line Arguments An important part of any program is the ability to communicate with the world external to it.

More information

Computational Methods of Scientific Programming Fall 2007

Computational Methods of Scientific Programming Fall 2007 MIT OpenCourseWare http://ocw.mit.edu 12.010 Computational Methods of Scientific Programming Fall 2007 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

More information

2 Compiling a C program

2 Compiling a C program 2 Compiling a C program This chapter describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header

More information

Jeden z variantov príkazu priradenia nám umožňuje zadať za sebou aj viacej vstupných hodnôt, ako napríklad

Jeden z variantov príkazu priradenia nám umožňuje zadať za sebou aj viacej vstupných hodnôt, ako napríklad Príkaz priradenia Príkaz priradenia slúži na priradenie hodnoty premennej. Má tvar premenná = výraz, kde premenná je identifikátor, znak = sa číta priraď a vyhodnotením výrazu sa získa hodnota určitého

More information

BETA BASIC 3.0 (C) Betasoft 1985, 92 Oxford Road, Masley, Birmingham

BETA BASIC 3.0 (C) Betasoft 1985, 92 Oxford Road, Masley, Birmingham BETA BASIC 3.0 (C) Betasoft 1985, 92 Oxford Road, Masley, Birmingham PREHĽAD...2 PRÍKAZY:...2 FUNKCIE:...3 ÚVOD...4 EDITÁCIA...4 PROCEDÚRY A PARAMETRE...5 Referencie, alebo odovzdávanie parametra adresou:...7

More information

Arrays and Strings. Antonio Carzaniga. February 23, Faculty of Informatics Università della Svizzera italiana Antonio Carzaniga

Arrays and Strings. Antonio Carzaniga. February 23, Faculty of Informatics Università della Svizzera italiana Antonio Carzaniga Arrays and Strings Antonio Carzaniga Faculty of Informatics Università della Svizzera italiana February 23, 2015 Outline General memory model Definition and use of pointers Invalid pointers and common

More information

CS240: Programming in C. Lecture 2: Overview

CS240: Programming in C. Lecture 2: Overview CS240: Programming in C Lecture 2: Overview 1 Programming Model How does C view the world? Stack Memory code Globals 2 Programming Model Execution mediated via a stack function calls and returns local

More information

Darshan Institute of Engineering & Technology for Diploma Studies Unit 6

Darshan Institute of Engineering & Technology for Diploma Studies Unit 6 1. What is File management? In real life, we want to store data permanently so that later on we can retrieve it and reuse it. A file is a collection of bytes stored on a secondary storage device like hard

More information

Computer Architecture and Assembly Language. Practical Session 3

Computer Architecture and Assembly Language. Practical Session 3 Computer Architecture and Assembly Language Practical Session 3 Advanced Instructions division DIV r/m - unsigned integer division IDIV r/m - signed integer division Dividend Divisor Quotient Remainder

More information

File I/O. Preprocessor Macros

File I/O. Preprocessor Macros Computer Programming File I/O. Preprocessor Macros Marius Minea marius@cs.upt.ro 4 December 2017 Files and streams A file is a data resource on persistent storage (e.g. disk). File contents are typically

More information

ECE 2035 Programming HW/SW Systems Spring problems, 7 pages Exam One Solutions 4 February 2013

ECE 2035 Programming HW/SW Systems Spring problems, 7 pages Exam One Solutions 4 February 2013 Problem 1 (3 parts, 30 points) Code Fragments Part A (5 points) Write a MIPS code fragment that branches to label Target when register $1 is less than or equal to register $2. You may use only two instructions.

More information