1) They probably differ in being constants or non-constants.
3) It's "3d" because you have an extra pointer in the way. Every level of pointers requires another dereferencing operation to access it. One level pointer requires one. Two level pointer requires two. Three level pointer requires three. 97 level pointer requires 97. That is the pattern.
The first dereferencing operation gets rid of is x itself; once you do so, you are essentially accessing y. The next level of pointers points to individual rows inside y. The last level gets you an individual cell in that row.
The diagram is x -> y -> row -> column.
These 2 Users Gave Thanks to Corona688 For This Post:
void main()
{
int a={1,2,3,4,5,6,7,8,9,10};
int *p=a;
int *q=&a;
cout<<q-p+1<<endl;
}
The output is 10, how?
if we give cout<<q it will print the address, value won't print....
if we give cout<<p it will print the address, value won't print....
p has the base addr; q... (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)
Hi all,
Can anyone provide help with getting the right syntax regarding array/pointers in C in the following code? Can't locate a specific example which clarifies this...
Say I declare a typedef to an array of pointers to some type...
/**
* An array of ptrs to sections
*/
typedef... (4 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)
This code is to print out the program name and arguments list one by one:
1 #include<stdio.h>
2
3 void main(int argc, char *argv)
4 {
5 int iCount = 0;
6 while (iCount < argc) {
7 printf("argc:%d\t%s\n",iCount, argv);
8 ... (14 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)
how to copy content of character pointer to character array in c programming..
char *num;
char name=num; (1 Reply)
Discussion started by: zinat
1 Replies
LEARN ABOUT FREEBSD
alphasort
SCANDIR(3) BSD Library Functions Manual SCANDIR(3)NAME
scandir, alphasort -- scan a directory
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <dirent.h>
int
scandir(const char *dirname, struct dirent ***namelist, int (*select)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **));
int
scandir_b(const char *dirname, struct dirent ***namelist, int (*select(rp(const struct dirent *),
int (^compar)(const struct dirent **, const struct dirent **));
int
alphasort(const struct dirent **d1, const struct dirent **d2);
DESCRIPTION
The scandir() function reads the directory dirname and builds an array of pointers to directory entries using malloc(3). It returns the num-
ber of entries in the array. A pointer to the array of directory entries is stored in the location referenced by namelist.
The select argument 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 argument 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.
The alphasort() function is a routine which can be used for the compar argument to sort the array alphabetically using strcoll(3).
The memory allocated for the array can be deallocated with free(3), by freeing each pointer in the array and then the array itself.
The scandir_b() function behaves in the same way as scandir(), but takes blocks as arguments instead of function pointers and calls qsort_b()
rather than qsort().
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.
SEE ALSO directory(3), malloc(3), qsort(3), strcoll(3), dir(5)HISTORY
The scandir() and alphasort() functions appeared in 4.2BSD.
BSD January 3, 2010 BSD