Find the answer to your Linux question:
Results 1 to 4 of 4

Thread: c problem

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    c problem


    hi all,
    can u please tell me,

    int a=sizeof(L”TEXT”)

    What is the value of a?

  2. #2
    Linux Engineer
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    803
    write a simple program and print the value of the variable: a

    By the way "sizeof" is an operator not a function so what you have is:
    Code:
    int a = sizeof         (L"TEXT");

  3. #3
    hi,
    I am getting 20.how to get this answer?can u please explain?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    803
    The opertor, sizeof, returns the byte count storage needed for the operand, in this case the operand is
    Code:
    L"TEXT"
    This says that your literal string takes up 20 bytes of space.



    What is the value without the "L" being present? Why are this numbers different?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •