Thread: Calling init function through main in C

  1. #76
    Registered User
    Join Date
    Nov 2015
    Posts
    86
    Code:
    typedef struct Dip_gat
    {
        
            uint16_t inst
          
        union
        {
            
            int    k                 1;
     
        }
        data;
    
       int  f;
    }
    Dip;
    what if structwas like this? wouldi call it same way

  2. #77
    Registered User
    Join Date
    Nov 2015
    Posts
    86
    thank you

  3. #78
    Registered User
    Join Date
    Nov 2015
    Posts
    86
    Code:
    #include <stdio.h>
     
    typedef struct
    {
        int inst;
        void * t1;
    } Dip;
     
    int func(Dip *req)
    {
        int response;
     
        if (req->inst == 0)
        {
            response = 0;
        }
        else
        {
            response = 1;
        }
     
        return response;
    }
     
    int main(void)
    {
        int result;
        Dip req;
     
        req.inst = 1;
        result = func(&req);
        printf("inst=%d; result=%d\n", req.inst, result);
     
        //change value of t1
        t1 x;
        &x =1;
    
        req.inst = 0;
        result = func(&req);
        printf("inst=%d; result=%d\n", req.inst, result);
     
        return 0;
    }
    i want to be able to change value of t1

  4. #79
    Registered User
    Join Date
    Nov 2015
    Posts
    86
    prog.c: In function 'main':
    prog.c:29:5: error: unknown type name 't1'
    t1 x;
    ^
    prog.c:30:7: error: lvalue required as left operand of assignment
    &x=1;
    ^

  5. #80
    Registered User
    Join Date
    Nov 2015
    Posts
    86
    why is it giving me unknown type name
    what is l value?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 06-10-2013, 04:03 PM
  2. Calling this function in my main.
    By filadon in forum C Programming
    Replies: 3
    Last Post: 02-15-2011, 02:58 PM
  3. having some trouble calling a function in the main program
    By CMakesMeSad :( in forum C Programming
    Replies: 19
    Last Post: 06-26-2009, 09:33 PM
  4. calling a function inside main()
    By mero24 in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2005, 01:22 AM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM

Tags for this Thread