Shop OBEX P1 Docs P2 Docs Learn Events
FlexProp: initialize struct to other struct — Parallax Forums

FlexProp: initialize struct to other struct

I'm trying to copy one structures value to another struct. Code is like this:

struct StringPatch initPatch;
...some lines initializing the member values here...
struct StringPatch patch6 = initPatch;

and compiler is complaining: error: Unknown symbol initPatch

I thought this is legal. Is it not supported?

Comments

  • Think I sorted it out. Doesn't like the declaration of patch6 and the assignment on the same line. Works like this:


    struct StringPatch patch6;
    patch6 = initPatch;

  • That probably just means your code is busted.

    My contrived example here works.

    #include <stdio.h>
    
    struct LMAO {
        int a;
        int b;
    };
    
    
    int main() {
        struct LMAO test;
        test.a = 1;
        test.b = 2;
        struct LMAO foo = test;
        printf("%d %d",foo.a,foo.b);
    }
    
    
Sign In or Register to comment.