Thread: asterisk

  1. #1
    Registered User
    Join Date
    Oct 2017
    Posts
    22

    asterisk

    Hi,

    can the asterisk sign mean anything else in C other than pointers and arrays? What does it mean when it's in a bracket after a declaration like below?
    And what does it mean when a function like "realloc" is after (int *)?

    if ((blk->sss = (int *) realloc(blk->sss, sizeof(int) * (blk->no_sss + 1))) == NULL) { ...


    Thanks!

  2. #2
    Banned
    Join Date
    Aug 2017
    Posts
    861
    it is still a pointer.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Actually the (int *) is a cast, casting the return value from that function to an int* from the void* that the function returns.

    Jim

  4. #4
    Registered User
    Join Date
    Oct 2017
    Posts
    22
    Quote Originally Posted by jimblumberg View Post
    Actually the (int *) is a cast, casting the return value from that function to an int* from the void* that the function returns.

    Jim
    Thanks Jim, that helps a lot!

    And in the other part of the code when it's (int) *, what is the meaning? Why can't it be "size of int * (blk -> no_sss+1)"?
    I've been looking through textbook about pointers but I can't seem to find brackets in that form explained.

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Do you mean this?
    Code:
    sizeof(int) * (blk->no_sss + 1))
    In this case that * is the old fashioned multiplication symbol. The asterisk has several different meanings depending on content, in this content it is going to multiply the values on both sides of the operator.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. square of asterisk
    By lmanukyan in forum C Programming
    Replies: 1
    Last Post: 12-17-2015, 08:06 AM
  2. How can I get this asterisk shape?
    By shansajid in forum C Programming
    Replies: 5
    Last Post: 01-01-2013, 07:10 AM
  3. Asterisk Password
    By adnilsah017 in forum C Programming
    Replies: 4
    Last Post: 05-29-2011, 12:16 PM
  4. Password Asterisk
    By $l4xklynx in forum C Programming
    Replies: 5
    Last Post: 10-30-2008, 03:08 PM
  5. masked with asterisk(*)?
    By ShadeS_07 in forum C Programming
    Replies: 32
    Last Post: 10-25-2008, 12:16 PM

Tags for this Thread