"you're trying to initialize a struct, from a pointer."
I thought with the typedef...
This would mean that the following statement would be assigning a ptr to a ptr...
Because a region_t is a ptr type...or in other words, an array of section_t* ptrs. Hence my confusion, I thought in C an array and a ptr were essentially the same things, so this would work.
Anyway I got it to work by changing the assignment to the following...
I realised that "ctn.regions[nth]" is basically an array without the subscript, which means it's a ptr. And what it points to is a ptr to a "section_t"... voila a ptr to a ptr.
And I can access the section_t* by using the subscript, i.e...
Hi everybody,
i am newbie to unix and confused with file pointers and file descripters.
could anyone help me to clear my doubts ..
when we call unix system calls to create a file then we are dealing wih file descripters
i think file descripters are also normals file as stored inhard disks... (1 Reply)
All ..
I am having a pointer array . And trying to store the addess into that pointer array . please see below the problem i faced
code:
int cnt1;
char *t_array;
char *f_array;
for(cnt1=0; cnt1<1000; cnt1++)
{
t_array =... (1 Reply)
If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it:
(1) one is to pass a pointer-to-pointer parameter, like:
int my_malloc(int size, char **pmem)
{
*pmem=(char *)malloc(size);
if(*pmem==NULL)... (11 Replies)
if i create an array of pointers to a structure "struct node" as:
struct node *r;
and create "n" number of "linked lists" and assign it to the various struct pointers r using some function with a return type as structure pointer as:
r=multiplty(.......) /*some parameters*/
is... (2 Replies)
Hello,
The purpose of the program is to print a sub string from the prompt inputs. I do not understand why char pointer does not work but char array will for line 40 and Line 41.
./a.out thisisatest 0 8
substring = "thisisat"And my code is:
#include <stdio.h>
#include <stdlib.h>
#include... (29 Replies)
Here are two programs that pass a pointer to a variable but behave differently. Shouldnt the i in second program be 0 after the function call?
#include<stdio.h>
void changeI(int *i)
{
*i = 10;
}
int main(void)
{
int i=5;
printf("%d before\n", i);
changeI(&i);
printf("%d... (1 Reply)
Hi Friends,
I have a host(Suse Linux 10.4) which has 2 luns presented from 2 different arrays HP eva and xp. we are planning to migrate hp eva to 3par. When i look for physical volume i see /dev/dm-4, /dev/dm-5, /dev/dm-7and when i look for multipath -ll i see dm-8,dm-9,dm-7. So i can't confirm... (6 Replies)
I am struggling with the pointer to 2D-array (cf: 2D array of pointers). Can anybody help me elaborate how the pointer x moves in the memory to access the individual of y, especially the high lighted lines?
I have talked to one of the curators of the forum, but I am still not quite clear.
Here... (1 Reply)
Discussion started by: yifangt
1 Replies
LEARN ABOUT BSD
alphasort
SCANDIR(3) Library Functions Manual SCANDIR(3)NAME
scandir, alphasort - scan a directory
SYNOPSIS
#include <sys/types.h>
#include <sys/dir.h>
scandir(dirname, namelist, select, compar)
char *dirname;
struct direct *(*namelist[]);
int (*select)();
int (*compar)();
alphasort(d1, d2)
struct direct **d1, **d2;
DESCRIPTION
Scandir reads the directory dirname and builds an array of pointers to directory entries using malloc(3). It returns the number of entries
in the array and a pointer to the array through namelist.
The select parameter is a pointer to a user supplied subroutine which is called by scandir to select which entries are to be included in
the array. The select routine is passed a pointer to a directory entry and should return a non-zero value if the directory entry is to be
included in the array. If select is null, then all the directory entries will be included.
The compar parameter is a pointer to a user supplied subroutine which is passed to qsort(3) to sort the completed array. If this pointer is
null, the array is not sorted. Alphasort is a routine which can be used for the compar parameter to sort the array alphabetically.
The memory allocated for the array can be deallocated with free (see malloc(3)) by freeing each pointer in the array and the array itself.
SEE ALSO directory(3), malloc(3), qsort(3), dir(5)DIAGNOSTICS
Returns -1 if the directory cannot be opened for reading or if malloc(3) cannot allocate enough memory to hold all the data structures.
4.2 Berkeley Distribution September 17, 1985 SCANDIR(3)