Reputation: 305
I see this line right after include and before main function.
size_t getline(char **lineptr, size_t *n, FILE *stream);
What I can deduce
Where I'm stuck
*
s? I thought a single *
is for pointer.Upvotes: 0
Views: 534
Reputation: 504
Pointer variable needs memory to store value that is a address of memory. If you want to define a pointer variable to store address of a int type variable, you can define the pointer like this:
int *mypointer = NULL;
int x = 10;
//store the address of variable x
mypointer = &x;
As we know, the pointer variable is just to store someone's address that is just a number. Thus that pointer variable also has address in the memory space. How to store the pointer's address? We can do that like this:
int *mypointer = NULL;
int x = 10;
//the pointer store the x's address
mypointer = &x;
//define a pointer to store the pointer variable mypointer's address
int **newpointer = &mypointer;
So, char ** is similar with int **.
The type size_t is unsigned int or other type. Note size_t is unsigned type whatever size_t is type of int or someone else. Type ssize_t is signed type in C. For simplicity, size_t maybe define as follow:
typedef unsigned int size_t;
typedef int ssize_t;
Upvotes: 2
Reputation: 48121
size_t
is a type. It is probably defined in one of the header files that are included. The function returns a value of that type, and its second parameter is a pointer to a value of that type.
You are correct that *
indicates a pointer. So **
is a pointer to a pointer. So the function parameter lineptr
is the address of a location (A) in memory, which contains the address of another location (B) in memory; the data at the second location should be interpreted as char
values. This implies that the function could change the value stored at location A to point to some location other than B.
Upvotes: 3