Question: I am reading a book called C for Java Programmers. 
It gives an example about nameless structs that I do not undestand.
It says that this is valid:

```
struct{
 int val1, val2;
 double val3;
} s1,s2;

  s1.val1 = 5;
  s2.val3 = 4.6;

```

If structs are similar to objects in Java, why can't I just say val1 = 5 and val2 = 4.6?
What is the point of s1 and s2?

Thanks

Answer: 
With this code you are creating (or instantiating in OO terms) two distinct nameless struct "objects". It is equivalent to:

```
struct name{
  int val1, val2;
  double val3;
}

struct name s1;
struct name s2;

s1.val1 = 5;
s2.val3 = 4.6;

```

if you want to give a name to the struct. Alternatively, you can create structures with initializers as alk suggested.
By writing:

```
struct {
    int val1, val2;
    double val3;
} s1, s2;

```

inside, let's say, the `main` function; you declare two variables named `s1` and `s2`, which have the type `struct { int val1, val2; double val3; }` . This `struct { int val1, val2; double val3; }` is really similar to `int` or `char` or `float` , you can just think of it as a little longer type.

Now that you have the `s1` and `s2` , you can play with them, since they are variables, right? Well, if you had given a name to your `struct` then you'd have two ways of doing that, but since it doesn't have a name, you only have one way of doing it, and that is by changing individual contents that your `s1` and `s2` has. For example:

```
s1.val1 = 6;
s2.val3 = 5.2314;

```

If you had given a name to the `struct` , you'd have one another way of playing with its variables. Let's say you had given a name `abc` to it, like this:

```
struct abc {
    int val1, val2;
    double val3;
} s1, s2;

```

In that case, you can play around with the `s1` and `s2` as a whole, like this:

```
s1 = (struct abc) { 123, 234, 1.234 };
s2 = (struct abc) { 12, 34 };

```

For `s1` , it assigns `123` to `val1` , `234` to `val2` and `1.234` to `val3` . For `s2` , similar for first 2, and it assigns a `0` for the 3rd variable, because I've omitted that one.