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: 
`struct`s are similar to classes in the sense that you can view the members of a `struct` as public fields of a class. Because this struct has no name you only have the instances at the end of the `struct`'s declaration (`s1` and `s2`) because you'd need the `struct`'s name to make instances in other places.

In order to assign values to the members of the instances you need to access them through the instance (`s1` or `s2`). 

You can compare it with the following Java scenario: you have a class with three public fields: `val1`, `val2` and `val3` and you have two instances of your class: `s1` and `s2`. In order to assign values to your instances you need to access the members through the instances: 

```
s1.val1 = 5;
s2.val3 = 3.14;

```

The fact that the `struct` is nameless only means that you can't make other instances besides the ones at the end of the declaration, but has no effect on how you access the members of instances.
Coming from java you can think of a C struct like a class without member functions:

```
//java:
class SomeData1 {
    public int val1;
    public int val2;
    public double val3;
}

```

So then you'd do:

```
// java:
SomeData1 s1= new SomeData1();
s1.val1 = 5;

```

In C you can use a struct like this by naming the structure:

```
// C:
typedef struct {
  int val1, val2;
  double val3;
} SomeData1;

```

Then you can set values:

```
// C:
SomeData1 s1;
s1.val1 = 5;

```

But it's also possible to use a structure "nameless" as you've seen in the example you posted:

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

```

In this case you can still access the `s1` and `s2` structure's values:

```
s1.val1 = 5;

```

But you can't refer to the original structure... can't make additional instances (however many you declare initially, are the only ones you are going to get) of it. IMO the nameless structure isn't very useful.