Politechnika Śląska - strona 312

note /search

Quick Sort

  • Politechnika Śląska
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 448

Quick Sort  Find a random element x  Place elements = x in the right part  Call the function recursively for both parts (if they are longer than 1 element)  Complexity: O( n log n ) ( ...

Reading files

  • Politechnika Śląska
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 511

Reading files  A file may be rewound • may be done instead of storing a line in a buffer  A common task: saving and reading variables in/from files  How to organize a file  Binary file (closed format)  Text file (editable, larger, more dangerous)  Text files  Own format / syntax  XML ...

Signals

  • Politechnika Śląska
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 448

Signals  SIGABRT abnormal termination, e.g., from abort  SIGFPE arithmetic error, e.g., zero divide or overflow  SIGILL illegal function image, e.g., illegal instruction  SIGINT interactive attention, e.g., interrupt  SIGSEGV illegal storage ...

The gets function

  • Politechnika Śląska
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 378

The gets() function  Do not use this function!  It does not know how many characters can be safely stored in the string passed to it  Thus, if too many are read, memory will be corrupted  Use the fgets() function instead and read from stdin  R...

The preprocessor

  • Politechnika Śląska
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 427

The preprocessor  Preprocessing is the first step in the C program translation  The preprocessor provides its own language  It can be a very powerful tool to the programmer  All preprocessor directives or commands begin with a # ...

Time measurement

  • Politechnika Śląska
  • Fundamentals of Computer Programming
Pobrań: 14
Wyświetleń: 448

Time measurement  Functions: asctime ctime difftime ftime gettime gmtime localtime mktime settime time_t tzset  Continuous time in seconds - Starting date: January 1st, 1970 - Type: long int (signed, 32-bits integer) - Maximum value: 2 31 -1 = 2 147 483 647 - What happens in 2 31 -1 seconds from ...

To use macros with parameters

  • Politechnika Śląska
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 287

To use macros with parameters or not to use  In C: useful, but be careful  In C++: better use templates ...

A structural example _ person

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 350

A structural example - person struct person { int age; char FName[20], LName[30]; }; void person_input(person *o); void person_set(person *o, int age, char *pFN, char *pLN); void person_output(person *o);  no access control over data members  the programmer is responsible for using proper functio...

An OO example _ person

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 462

An OO example - person class person { int age; // class members - class variables char FName[20], LName[30]; public: void input(); // class members - class methods void set(int age, char *pFN, char *pLN); void output(); }; // declaration ends with „ ; ”  data and methods together  default for cla...

Memset

  • Politechnika Śląska
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 630

Memset  void *memset (void *s, int c, size_t n);  memset sets the first n bytes of the array s to the character c  Returns s ...