Politechnika Śląska - strona 329

Structures

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

Structures  Structures in C++ are classes too struct A { contents... } is equivalent to class A { public: contents... } ...

3D libraries

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

3D libraries  General idea: - define lighting, viewpoint etc. - define 3D objects - leave the rest of the work the graphical engine  Usually used with a hardware accelerated video card ...

Atof

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

stdlib.h: atof double atof(const char *s)  Converts a string to double - ASCII string to floating point number  Problems with error detection (always returns a number)  Better control: strtod ...

Avoiding duplicate code for the preprocessor

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

Avoiding duplicate code for the preprocessor  Important!  An example of a header file bool.h: #ifndef BOOL_H #define BOOL_H enum bool {false, true}; #endif ...

Error messages

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

Error messages  Get a system error message char *strerror( int errnum );  Constants extern int _doserrno; extern int errno; extern char *_sys_errlist[ ]; extern int _sys_nerr; ...

Hyperbolic functions

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

Hyperbolic functions  sinh(x) hyperbolic sine of x  cosh(x) hyperbolic cosine of x  tanh(x) hyperbolic tangent of x ...

OpenGL

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

OpenGL void DisplayCallback(void) { glClear(GL_COLOR_BUFFER_BIT); /* Draw a triangle */ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(.5, 0.0, 0.0); glVertex3f(.5, .5, 0.0); glEnd(); glFlush(); } ...

Qsort

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

Qsort  Sorting of data - a common task performed by computers  There are many methods of sorting  One of the fastest is Quick Sort ...

Reading data from the keyboard

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

Reading data from the keyboard  Functions: - getc(), gets(), scanf() - fgetc(), fgets(), fscanf()  The keyboard is usually line buffered  Do not use gets() ...

Truncating

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

Truncating  ceil(x) smallest integer not less than x , as a double  floor(x) largest integer not greater than x , as a double ...