Sponsored Content
Full Discussion: Pointers and array
Top Forums Programming Pointers and array Post 57650 by dianazheng on Thursday 4th of November 2004 05:05:06 AM
Old 11-04-2004
Pointers and array

hi all,
let say i have a pointer exit, and this exit will store some value. how can i store the value that the pointer points to into an array and then print them out from the array.

thanks in advance
 

10 More Discussions You Might Find Interesting

1. Programming

pointers

is this a valid c declaration int (*ptr(int *b)); plz explain... (4 Replies)
Discussion started by: areef4u
4 Replies

2. Programming

pointers

Hi I mash with pointers in C. I solve this problem about 5 hours and I don't know how I should continue. void InsertFirst (tList *L, int val) { tElemPtr new; if((new = malloc(sizeof(tElemPtr))) == NULL) Error(); new->data = val; new->ptr = L->frst; L->frst = new;... (2 Replies)
Discussion started by: Milla
2 Replies

3. Programming

restricted pointers

Hi all. I am trying to use restricted pointers to allow the gcc compiler optimize the code, but I have not been able to make it work so far. I am testing with this code: #include <stdlib.h> #include <stdio.h> #include <time.h> #include <sys/time.h> void vecmult(int n, int * restrict a, int... (0 Replies)
Discussion started by: carl.alv
0 Replies

4. UNIX for Advanced & Expert Users

shared pointers

I am new to shared pointer conceot in C++ and hence require some clarification: For example: class A { public: virtual ~A() { } int x; }; typedef boost::shared_ptr<A>... (1 Reply)
Discussion started by: uunniixx
1 Replies

5. Programming

Need help with the Pointers in C

I have a special character called ô. When it is declared as a character variable its showing it can be printed. But when it is declared as a character pointer variable its showing it cannot be printed. I am just wondering why its happening like this.. c1 = '@'; c2 = 'ô'; char *fp; fp="XXô"; if... (1 Reply)
Discussion started by: sivakumar.rj
1 Replies

6. Programming

Problem with array of pointers

Hi All, I am using the array of pointers and storing the address of string.This is a global list. So i am using extern to give the reference of this list to another file and using reading the data from this string. But list is being corrupted and string is missing some characters in... (2 Replies)
Discussion started by: lovevijay03
2 Replies

7. Programming

Traversing in Array of pointers

Please find the below program. the requirement and description of the program also given: ganesh@ubuntu:~/my_programs/c/letusc/chap9$ cat fa.c.old /* Program : write a program to count the number of 'e' in thefollowing array of pointers to strings: char *s = { "We will teach you how... (12 Replies)
Discussion started by: ramkrix
12 Replies

8. Programming

Problem With Pointers

Hi guys. What is the difference between these: 1. int *a; 2. int (*a); (2 Replies)
Discussion started by: majid.merkava
2 Replies

9. Programming

Pointers and array

Hello, I read from a book exercise for a challenge. How to print out each letter of char array a by two different pointers pa and ppa in the example? I have tried my code for letter "r" by testing without full understanding as only the first one worked. #include<stdio.h> int main() { char... (17 Replies)
Discussion started by: yifangt
17 Replies

10. Programming

How to Declare an array of function pointers?

I am attempting to create an array of function pointers. The examples I follow to do this are from: support.microsoft.com/en-us/help/30580/how-to-declare-an-array-of-pointers-to-functions-in-visual-c ... (3 Replies)
Discussion started by: spflanze
3 Replies
JudyHS(3)						     Library Functions Manual							 JudyHS(3)

NAME
JudyHS macros - C library for creating and accessing a dynamic array, using an array-of-bytes of Length as an Index and a word as a Value. SYNOPSIS
cc [flags] sourcefiles -lJudy #include <Judy.h> Word_t * PValue; // JudyHS array element int Rc_int; // return flag Word_t Rc_word; // full word return value Pvoid_t PJHSArray = (Pvoid_t) NULL; // initialize JudyHS array uint8_t * Index; // array-of-bytes pointer Word_t Length; // number of bytes in Index JHSI( PValue, PJHSArray, Index, Length); // JudyHSIns() JHSD( Rc_int, PJHSArray, Index, Length); // JudyHSDel() JHSG( PValue, PJHSArray, Index, Length); // JudyHSGet() JHSFA(Rc_word, PJHSArray); // JudyHSFreeArray() DESCRIPTION
A JudyHS array is the equivalent of an array of word-sized value/pointers. An Index is a pointer to an array-of-bytes of specified length: Length. Rather than using a null terminated string, this difference from JudySL(3) allows strings to contain all bits (specifically the null character). This new addition (May 2004) to Judy arrays is a hybird using the best capabilities of hashing and Judy methods. JudyHS does not have a poor performance case where knowledge of the hash algorithm can be used to degrade the performance. Since JudyHS is based on a hash method, Indexes are not stored in any particular order. Therefore the JudyHSFirst(), JudyHSNext(), JudyH- SPrev() and JudyHSLast() neighbor search functions are not practical. The Length of each array-of-bytes can be from 0 to the limits of malloc() (about 2GB). The hallmark of JudyHS is speed with scalability, but memory efficiency is excellent. The speed is very competitive with the best hashing methods. The memory efficiency is similar to a linked list of the same Indexes and Values. JudyHS is designed to scale from 0 to billions of Indexes. A JudyHS array is allocated with a NULL pointer Pvoid_t PJHSArray = (Pvoid_t) NULL; Because the macro forms of the API have a simpler error handling interface than the equivalent functions, they are the preferred way to use JudyHS. JHSI(PValue, PJHSArray, Index, Length) // JudyHSIns() Given a pointer to a JudyHS array (PJHSArray), insert an Index string of length: Length and a Value into the JudyHS array: PJHSArray. If the Index is successfully inserted, the Value is initialized to 0. If the Index was already present, the Value is not modified. Return PValue pointing to Value. Your program should use this pointer to read or modify the Value, for example: Value = *PValue; *PValue = 1234; Note: JHSI() and JHSD can reorganize the JudyHS array. Therefore, pointers returned from previous JudyHS calls become invalid and must be re-acquired (using JHSG()). JHSD(Rc_int, PJHSArray, Index, Length) // JudyHSDel() Given a pointer to a JudyHS array (PJHSArray), delete the specified Index along with the Value from the JudyHS array. Return Rc_int set to 1 if successfully removed from the array. Return Rc_int set to 0 if Index was not present. JHSG(PValue, PJHSArray, Index, Length) // JudyHSGet() Given a pointer to a JudyHS array (PJHSArray), find Value associated with Index. Return PValue pointing to Index's Value. Return PValue set to NULL if the Index was not present. JHSFA(Rc_word, PJHSArray) // JudyHSFreeArray() Given a pointer to a JudyHS array (PJHSArray), free the entire array. Return Rc_word set to the number of bytes freed and PJHSArray set to NULL. ERRORS
: See: Judy_3.htm#ERRORS EXAMPLES
Show how to program with the JudyHS macros. This program will print duplicate lines and their line number from stdin. #include <unistd.h> #include <stdio.h> #include <string.h> #include <Judy.h> // Compiled: // cc -O PrintDupLines.c -lJudy -o PrintDupLines #define MAXLINE 1000000 /* max fgets length of line */ uint8_t Index[MAXLINE]; // string to check int // Usage: PrintDupLines < file main() { Pvoid_t PJArray = (PWord_t)NULL; // Judy array. PWord_t PValue; // Judy array element pointer. Word_t Bytes; // size of JudyHS array. Word_t LineNumb = 0; // current line number Word_t Dups = 0; // number of duplicate lines while (fgets(Index, MAXLINE, stdin) != (char *)NULL) { LineNumb++; // line number // store string into array JHSI(PValue, PJArray, Index, strlen(Index)); if (PValue == PJERR) // See ERRORS section { fprintf(stderr, "Out of memory -- exit "); exit(1); } if (*PValue == 0) // check if duplicate { Dups++; printf("Duplicate lines %lu:%lu:%s", *PValue, LineNumb, Index); } else { *PValue = LineNumb; // store Line number } } printf("%lu Duplicates, free JudyHS array of %lu Lines ", Dups, LineNumb - Dups); JHSFA(Bytes, PJArray); // free JudyHS array printf("JudyHSFreeArray() free'ed %lu bytes of memory ", Bytes); return (0); } AUTHOR
JudyHS was invented and implemented by Doug Baskins after retiring from Hewlett-Packard. SEE ALSO
Judy(3), Judy1(3), JudyL(3), JudySL(3), malloc(), the Judy website, http://judy.sourceforge.net, for further information and Application Notes. JudyHS(3)
All times are GMT -4. The time now is 08:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy