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?

Structures 1: Simple Structure, Nested Structure, The C Puzzle book, p.63

Last updated at Posted at 2025-06-11

Puzzle book
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

cf1.c, The C Puzzle Book
https://qiita.com/kaizen_nagoya/items/6b6c4b055b279502b13e

cf2.c THe C Puzzle book
https://qiita.com/kaizen_nagoya/items/0b05578f5d110487a1d3

cf3.c The C Puzzle Book
https://qiita.com/kaizen_nagoya/items/61c4c9c7382d5425d5f6

cf4.c The C Puzzle Book
https://qiita.com/kaizen_nagoya/items/2900320cb219aaa07211

program style 1, The C Puzzle book
https://qiita.com/kaizen_nagoya/items/9870d16747a82df61c58

The C Puzzle Book: Operators 1: Basic Arthmetic Operations
https://qiita.com/kaizen_nagoya/items/2a0d8277d72bfc579df6

c puzzle book op6.c
https://qiita.com/kaizen_nagoya/items/cd7a04de6b846becb2a4

c puzzle book op6.c install error
https://qiita.com/kaizen_nagoya/items/4542e50784561d5d3d3e

c puzzle book basic type 1
https://qiita.com/kaizen_nagoya/items/fdf42293421b7705c14f

c puzzle book basic type 2.c
https://qiita.com/kaizen_nagoya/items/81fb10b331cc7be90654

c puzzle book basic type 3
https://qiita.com/kaizen_nagoya/items/9c01c980c15951c6a3ef

C Puzzle Bookをやる動機
https://qiita.com/kaizen_nagoya/items/962034c4e3812aeadee5

C++版 C PuzzleBook
https://qiita.com/kaizen_nagoya/items/5dd0fe4700b39c2ccea3

Structures 1: Simple Structure, Nested Structure, p.63

st1.c
// The C Puzzle book p.63 Alan R. Feuer Bell Laboratories, Murray Hill, New Jersey
// Structures 1: Simple Structure, Nested Structure, The C Puzzle book, p.63
// https://qiita.com/kaizen_nagoya/items/f32769f4e76f5cc05776
// Dr. Kiyoshi Ogawa, 2025/06/11
#include "defs.h"

int main(void){
        static struct S1{
                char c[4], *s;
        } s1 = {"abc", "def"};

        static struct S2 {
                char * cp;
                struct S1 ss1;
        } s2 = { "ghi", { "jkl", "mno" }} ;

        PRINT2(c, s1.c[0], *s1.s);
        PRINT2(s, s1.c, s1.s);

        PRINT2(s, s2.cp, s2.ss1.s);
        PRINT2(s, ++s2.cp, ++s2.ss1.s);
}

comile and go

bash
$ gcc st1.c
$ ./a.out
s1.c[0] = a     *s1.s = d
s1.c = abc      s1.s = def
s2.cp = ghi     s2.ss1.s = mno
++s2.cp = hi    ++s2.ss1.s = no
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?