Forum

Register Keyword

This thread contains 1 reply, has 2 voices, and was last updated by  Nitesh User Do not delete 9 months, 1 week ago.

  • Author Replies
  • #53729

    What Is The Use Of Register Keyword With The Variables?


  • #53731

    1) Register keyword implies that of conceivable to store the variable in the register than store it in the register.

    2) Variables are generally stored in stacks and are passed back and forth to a processor at whatever point required.

    3) Also, register keyword when utilized decreased code size which is something critical in an embedded system.

    Registers are quicker than memory to get to, so the variables which are most every now and again utilized in a C program can be placed in registers utilizing register keyword. The keyword register clues to the compiler that a given variable can be placed in a register. It’s compiler’s decision to place it in a register or not.

    1) If you use an operator with a register variable then the compiler may give an error or cautioning : –

    int main()
    {
    register int i = 10;
    int *a = &i;
    printf(“%d”, *a);
    getchar();
    return 0;
    }

    2) Register keyword can be utilized with Pointer Variables: –

    int main()
    {
    int i = 10;
    register int *a = &i;
    printf(“%d”, *a);
    getchar();
    return 0;
    }

    3) The register is a storage class, and C doesn’t permit different storage class specifiers for a variable: –

    int main()
    {
    int i = 10;
    register static int *a = &i;
    printf(“%d”, *a);
    getchar();
    return 0;
    }

    There is no restriction on a number of register variables in a C program, yet the fact of the matter is compiler may put a few variables in the register and some not.


    Regards,
    Nitesh Bavishiya

You must be to reply to this thread.Please or . Registration is 100% free.

GET FREE CONSULTATION

Call Us Now For Free Consultation97370 05566

Our experts listen to you patiently and suggest you the right course after conducting a personality profile test. Register your interest below to schedule personality profile test for you.

SUBSCRIBE TO OUR NEWSLETTER

Contact Us

Working Hours

  • Monday9:00 AM – 9:00 PM
  • Tuesday9:00 AM – 9:00 PM
  • Wednesday9:00 AM – 9:00 PM
  • Thursday9:00 AM – 9:00 PM
  • Friday9:00 AM – 9:00 PM
  • Saturday9:00 AM – 9:00 PM
  • SundayClosed
Copyright 2016-2019 Smart Mentors. All Rights Reserved.

Login

FORGOT PASSWORD

Sign up now to Become An Instructor

Register your Interest