Politechnika Śląska - strona 127

note /search

Itoa - overview

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

Itoa A conversion from an i nteger to A SCII string /* itoa: convert n to characters in s */ void itoa(int n, char s[]) { int i, sign; if ((sign = (n 0); /* delete it */ if (sign) s[i++] = '-'; /* n was negative */ s[i] = '\0'; /* mark the end of ...

Limits - overview

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

#define CHAR_BIT 8 /* number of bits in a char */ #define SCHAR_MIN (-128) /* minimum signed char value */ #define SCHAR_MAX 127 /* maximum signed char value */ #define UCHAR_MAX 0xff /* maximum unsigned char value */ #ifndef _CHAR_UNSIGNED #define CHAR_MIN SCHAR_MIN /* mimimum char value */ #defi...

Malloc and free - overview

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

malloc and free • Allocating memory: void *malloc(size_t size); if unsuccessful, returns NULL • Freeing memory: void free(void *block); • Memory is allocated on the heap #include /* printf */ #inc...

New and delete - overview

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

new and delete • new and delete are operators that create and destroy an object • Syntax for a single object: = new ; delete ; • Example for a single object: int *ptr; /* int or any non-function...

Passing two dimensional arrays to functions

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

Passing t wo-dimensional arrays to functions • At least the number of colums should be defined in the parameter declaration • The number of rows is irrelevant • The function gets a pointer to an array of rows • Passing daytab to a function f : f(i...

Pointers to structures - overview

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

Pointers to structures typedef struct { int k; double x; } my_str; my_str *p; p = (my_str*)malloc(sizeof(my_str)); if (p==NULL) fprintf(stderr,"Out of memory...\n"); else { (*p).k = 9; /* *p.k is incorrect */ p-k = 10; /* works like (*p)....

Pointers vs multidimensional arrays

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

Pointers vs. multi- dimensional arrays • For these definitions: int a[10][20]; and int *b[10]; • Expressions a[3][4] and b[3][4] refer to a single int . • But: - a is a true two-dimensional array with 200 integers - the location of a[row,col] in memory...

Standards - overview

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

Standards • C - The C programming language, K&R, (1978) - ANSI C or C89 (1989) - C99 (1999) - C1X (2011/12) • C++ - C++98 (1998) - C++03 (2003) - C++TR1 (2007) - C++11 (2011, ISO/IEC 14882:2011) ...

The alphabet - overview

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

The alphabet Both the basic source and basic execution character sets shall have at least the following members: • the 26 uppercase letters of the Latin alphabet: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z • the 26 lowercase letters of the Latin alphabet: a b c d e f g h i j k l m n o p q ...

The Julian and Gregorian calendars

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

The Julian and Gregorian calendars • The true length of the year: 365.242189 days • The mean length of the year in the Julian calendar (used before 1582): 365.25 days (1 leap year every 4 years) • There is a difference of 0.007811 days • What to do with the a difference of 0.007811 days • Remove 3 ...