Thread: A pointer looka like a function, what is it?

  1. #1
    Registered User
    Join Date
    Mar 2023
    Posts
    2

    A pointer looka like a function, what is it?

    Code:
    node * ekleSirali(node * r, int x){ if(r==NULL){//linklist bossa  r=(node*)malloc(sizeof(node));  r->next= NULL;  r->x = x;  return r; }
    


    "node * ekleSirali(node * r, int x)" what is this structure, i mean it's looking like a pointer but like a function it has parameter and a return value. I've never seen that before. what is it called?


  2. #2
    Registered User
    Join Date
    Sep 2020
    Posts
    425
    I've reformatted that code a bit, and it's incomplete, making it hard to reason about:

    Code:
    node * ekleSirali(node * r, int x) { 
        if(r==NULL)
        {  
             //linklist
             bossa  r=(node*)malloc(sizeof(node)); 
             r->next= NULL; 
             r->x = x;  
             return r; 
        }
    It is just a function that returns a pointer to a "node".

    You call the function, and it returns the the address in memory of where the node is stored.

  3. #3
    Registered User
    Join Date
    Mar 2023
    Posts
    2
    looks much better. Thanks for the reply...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 02-09-2022, 06:08 AM
  2. Replies: 8
    Last Post: 03-01-2015, 12:39 AM
  3. Replies: 3
    Last Post: 03-14-2013, 03:25 PM
  4. Function pointer and Member function pointer usage?
    By freiza in forum C++ Programming
    Replies: 4
    Last Post: 05-30-2012, 08:17 AM
  5. Replies: 7
    Last Post: 07-04-2007, 12:46 PM

Tags for this Thread