0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

storage class 2: Functions, The C Puzzle book

0
Posted at

職業訓練
https://qiita.com/kaizen_nagoya/items/95368b63fa21d64271ec

Programmer, Day 6
https://qiita.com/kaizen_nagoya/items/632d8f191268e88eb86a

C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識, error(21), coding(28)
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9

The C Puzzle Book
https://efrei.poupa.net/Programmation%20en%20C/Cours/The_C_Puzzle_Book.pdf

defs.h "The C Puzzle Book"
https://qiita.com/kaizen_nagoya/items/6d284651ac1244963bd9

sc2.c
#define LOW 0
#define HIGH 5
#define CHANGE 2

int i=LOW;

void main(void)
{
        auto int i=HIGH;
        reset( i/2 ); PRINT1(d,i);
        reset( i=i/2 ); PRINT1(d,i);
        i = reset( i/2 ); PRINT1(d,i);

        workover(i); PRINT1(d,i);       // (Storage Classes 2.1)
}

int workover(int i)
{
        i = (i%i) * ((i+1)/(2*i) + 4);
        PRINT1(d,i);
        return(i);
}

int reset(int i)
{
        i = i<=CHANGE ? HIGH : LOW;
        return(i);
}




bash
$ gcc sc2a.c
sc2a.c: In function ‘main’:
sc2a.c:12:9: warning: implicit declaration of function ‘reset’ [-Wimplicit-function-declaration]
   12 |         reset( i/2 ); PRINT1(d,i);
      |         ^~~~~
sc2a.c:16:9: warning: implicit declaration of function ‘workover’ [-Wimplicit-function-declaration]
   16 |         workover(i); PRINT1(d,i);       // (Storage Classes 2.1)
      |         ^~~~~~~~
inst19@teachB:~$ ./a.out
i = 5
i = 2
i = 5
i = 0
i = 5
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?