Why structs cannot be assigned directly?
        Posted  
        
            by 
                becko
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by becko
        
        
        
        Published on 2012-08-30T03:34:17Z
        Indexed on 
            2012/08/30
            3:38 UTC
        
        
        Read the original article
        Hit count: 128
        
c
Suppose I have a fully defined struct with tag MyStruct, and suppose that x, y, ..., z are allowed values for its fields. Why is
struct MyStruct q = {x,y,..,z};
allowed, but
struct MyStruct q;
q = {x,y,...,z};
is not allowed? I find this very annoying. In the second case, where I have previously declared q, I need to assign a value to each field, one by one:
q.X = x; q.Y = y; ... q.Z = z;
where X, Y, ..., Z are the fields of MyStruct. Is there a reason behind this?
© Stack Overflow or respective owner