Politechnika Śląska - strona 302

note /search

Inserting elements - overview

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

inserting elements void insert(double a, struct stag **h) { struct stag *p; p = (struct stag*)malloc(sizeof(struct stag)); if (!p) exit(1); p-x = a; p-next = *h; *h = p; } head = NULL; insert(45.6, &head); insert(54.3, &head); insert(1234, &head); ...

Modifications of list - overview

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

Modifications • Appending at the en d requires a pointer to the last element - store a pointer to the tail of the list • Walking through elements is possible in only one direction - store pointers to the previous element in each element, creating ...

Nesting unions and structures

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

Nesting unions and structures • Unions may be defined in struc tures and arrays, and vice versa • Syntax for accessing elements: like structures • Example: struct { char *name; int flags; int utype; union { int i; float f; char *s; } u; } symtab[N...

Other functions operating on files

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

Other functions operating on files • feof Tests for end-of-file on a stream int feof( FILE * stream ); • returns a nonzero value after the first read operation that attempts to read past the end of the file • It returns 0 if the current position is not end of file • There is no error return ...

Other operations on lists

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

Other operations on lists • Looking for an element • Appending an element after the last element of the list • Inserting an element at a given position • Removing an element • Ch anging the order of elements • Insert an element at a known position:...

Parts of a C program

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

Parts of a C program • A C program, whatever its size, consis ts of functions and variables • A function contains statements that specify the computing operations to be done • Variables store values used during the computation ...

Passing arrays to functions

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

Passing arrays to functions • When the name of an array is used as an argument, the value passed to the function is the location or address of the beginning of the array • There is no copying of array elements! • More details on passing parameters to functions: later ...

Passing values to functions

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

Passing values to functions • All function arguments are passed ''by value'' • The called function gets a copy of arguments • If you really need to modify a variable in a calling routine: - pass a pointer to it - the function will modify this plac...

Programming - overview

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

Programming • The CPU understands only machine code Hexacedimal version: 23 D1 8A 06 46 C1 E9 02 47 83 F8 08 Assembler mnemonics: mov al,byte ptr [esi] mov byte ptr [edi],al inc esi shr ecx,2 inc edi cmp ecx,8 assembler is called second generation language ...

Prototypes of functions - overview

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

Prototypes of functions • The compiler needs to recognise an identifier as a function name before you use it; the list of parameters should also be known • You may: - define a function before calling it, or - declare a function before calling it using a prototype and define it later • The declarati...