Politechnika Śląska - strona 303

Remove - overview

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

remove (unlink) Removes a file specified by filename int remove(const char *filename); • Example: #include int main(void) { char file[80]; /* prompt for file name to delete */

Rewind - overview

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

Rewind Repositions the file pointer to the beginning of a file void rewind( FILE * stream ); • repositions the file pointer to the beginning of the file • A call to rewind is similar to (void) fseek( stream , 0L, SEEK_SET ); • unlike fseek , rewin...

Rules of Type conversion

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

Type conversions - rules • If there are no unsigned operands, use this set of rules: - If either operand is long double , convert the other to long double . - Otherwise, if either operand is double , convert the other to double . - Otherwise, if e...

Scanf example - overview

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

scanf example #include int main() { int x; printf(” Enter a number: ”); scanf(”%d”, &x); printf(”The square of %d is %d\n”, x, x*x); return 0; } Warning: scanf is dangerous. ...

Skipping an iteration - overview

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

Skipping an iteration: continue • continue causes the next iteration of the enclosing for , while , or do loop to begin • In while and do : jump to the test part • In for : jump to the increment step (and then test) • The continue does not apply to switch • A continue in switch which is in a loop c...

Strings as arrays - overview

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

Strings as arrays • Defining a variable capable of storing strings (texts): as an array of characters: char name[length] for example: char s[10]; • There is a '\0' at the end of the string • Take care about the length! • Functions operating on strings ...

Structures may be returned by functions

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

Structures may be returned by functions typedef struct { float re, im; } cplx; cplx mult(cplx c, float x) { c.im *= x; c.re *= x; return c; } ...

Structures - overview

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

Structures • A structure - consists of a sequence of named members of various types • struct starts a structure declaration (a list of declarations enclosed in braces) • An optional name called a structure tag may follow the word struct • Access: struct-name.member •

The complete set of escape sequences

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

The complete set of escape sequences \a alert (bell) character \\ backslash \b backspace \? question mark \f formfeed \' single quote \n newline \" double quote \r carriage return \ ooo octal number \t horizontal tab \x hh hexadecimal numbe...

The if statement - overview

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

The if statement • The general form is if ( expression ) statement1 else statement2 • One and only one of the two statements associated with an if-else is performed • If the expression is: - true, statement1 is executed; - if not, statement2 is executed. • Each statement can be a single statement o...