Politechnika Śląska - strona 324

Exit

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 581

Exit  Sometimes it's useful to break the execution of a program immediately void exit(int status); #include #include int main() { int status = 8; exit(status); /* Note: this line is never reached */ return 0; } ...

Graphics

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 504

Graphics  The C language definition does not tell anything about graphics  Graphics is system dependent  Usually: accessed via a library of functions ...

Makefile dependency rules

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 469

Makefile depe ndency rules  A rule defines under what conditions a given file (or a type of file) needs to be re-compiled  Explicit rules additionally define commands required to compile a file  General form: targetfile : sourcefiles commands ...

Mathematical functions

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 448

Mathematical functions  Header file: math.h  Some systems require manual linking with a mathematical library (libm)  Speed: depends on the data type and processor capabilities - MIPS - FLOPS  Parallel computing: powerful, but more difficult to ...

Microsoft Windows GDI

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 427

Microsoft Windows GDI  The programmer provides a function drawing the whole contens of a window whenever the OS asks for it  The function gets a handle of a device  There is a number of graphics functions ...

Perror example

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 539

perror example #include int main() { FILE *fp; fp = fopen("perror.dat", "r"); if (!fp) perror("Unable to open file for reading"); return 0; }  Output: Unable to open file for reading: No such file or directory ...

Pitfalls

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 455

pitfalls  Consider following use of max : max(i++, j++)  The larger variable will be incremented twice!  Analyze this macro: #define square(x) x * x and it 's use: y = square(z+1);  The result: y = z + 1 * z + 1 ...

System

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 581

System int system(const char *command);  Executes a command  Example (Windows, DOS): #include #include int main() { printf("Files:\n"); system(" dir"); return 0; } ...

The scanf function

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 378

The scanf() function  Can also be used dangerously  The %s format can overwrite the destination string  However, it can be used safely by specifying a width  For example, the format %20s will not read more than 20 characters ...

A default pointer value

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Computer Programming
Pobrań: 0
Wyświetleń: 385

A default pointer value  … use a space between * and =  Correct: - void f(char* ="Abc"); - void g(int * = NULL); - void g(int* =NULL);  Wrong: - void f(char*="Abc"); - void g(int *= NULL); - void g(int*=NULL); ...