Results 1 to 5 of 5

Thread: why to use * at the start of a C expression?

  1. #1
    Join Date
    Nov 2009
    Posts
    42

    why to use * at the start of a C expression?

    Hello friends,
    I am new to this forum. I recently started learning c-language. I want to know whats is importance of "*" at the start of an expression. Like below example.

    Code:
    If (this == thiscars)
    ThisThings = *((WORDs *) &Array[withThispor]);
    Can anyone tell me why to use * at the start of a C expression?
    Please help me.

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: why to use * at the start of a C expression?

    Hey just try to understand following program. It is very simple one. After this you come to know for what purpose "*" use at the start of a C expression?. Just try to understand it line bu line.

    Code:
    #include <stdio.h>
    
    int main(int argc, char **argv) { 
         int *k_ptrs;
         int k, l;
    
         k = 5;
         k_ptr = &i;
    
         l= *k_ptr;
    
         printf("%d\n", l);
         return 0;
    }

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: why to use * at the start of a C expression?

    Hey "*" is used to define pointer. It is used to store memory location of other value. When you assign any value to any variable which has "*" then you actually assign address of that value. After assigning value you can store this address into a "pointer variable". When you have the address of the particular box and if you want to to visit the box then you have to get the value out you use.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: why to use * at the start of a C expression?

    Just try to understand following code. In this code I have use "*" to define one pointer. In the following program I have use withThisPoeg array to store all values.

    Code:
    &Array[withThisPosition]
    
    (WORD *)
    This code presume the pointer returned by &Array[withThisPoeg]. It is actually a pointer to a word.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: why to use * at the start of a C expression?

    "*" symbol is used to define pointer. I have written following program for you. Just try to understand it. It very simple to use. Just try to understand each line carefully. In this program I have use "withThisPosEg" pointer.

    Code:
    If (thiss == thisThingOverHeEg) {
      void *pointerToArrayELeEg;
      WORD *pointerToWORDEg;
      WORD results;
    
      pointerToArrayElements = &Array[withThisPosEg];
      pointerToWORDs = (WORD *)pointerToArrayEleEg;
      results = *pointersToWORDs;
    
      ThisThing = results;

Similar Threads

  1. Expression Web 2 freezes under Windows 7
    By Isidoro in forum Windows Software
    Replies: 6
    Last Post: 05-04-2010, 11:50 PM
  2. Regular expression Help in asp.net for DOB.
    By maheshmartha in forum Software Development
    Replies: 2
    Last Post: 06-03-2010, 07:06 AM
  3. Convert php expression
    By SoftWore in forum Software Development
    Replies: 3
    Last Post: 05-12-2009, 02:21 PM
  4. When will Expression Blend 3 be available
    By Madison in forum Windows Software
    Replies: 3
    Last Post: 15-07-2009, 09:26 PM
  5. Access - Expression for Request
    By Wiro in forum Software Development
    Replies: 4
    Last Post: 01-04-2009, 11:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,064,670.71575 seconds with 17 queries