Sponsored Content
Full Discussion: Reg: char ptr - Coredumps
Top Forums Programming Reg: char ptr - Coredumps Post 60326 by jim mcnamara on Friday 14th of January 2005 05:48:19 PM
Old 01-14-2005
Depending on Endian-ness and other things, printf may not encounter a zero (NUL) byte in an int = 1. This would say stop printing. I'd say printf() kept on into la-la land. segfault.

Try this something like hack and please don't use void main Smilie It will get revenge on you sooner or later.
Code:
int main( )
{
    int Index=0xff;
    char *type = (char *) &Index;
    int i=0;
    for(i=0;i<sizeof(int); i++)
    {
         printf("%d ", *type++);
    }
    printf("\n");
    return 0;
}

Assuming this is what you are trying to do. ASCII 1 doesn't display on most terminals.
 

10 More Discussions You Might Find Interesting

1. Programming

file ptr.

Is there any way to know the filename from an available file pointer. (2 Replies)
Discussion started by: bankpro
2 Replies

2. AIX

Configuring Color Laser ptr in AIX

Hi All, I have Network color laser printer which is to be configured in AIX5L. The Model of the printer is OKI C3200. Will it is supported with AIX 5..? I could not find any drivers for this. Will any compatible drivers are available for this printer... I tried with the default drivers hplj-4... (2 Replies)
Discussion started by: helloajith
2 Replies

3. Solaris

Coredumps and swap - was part of Solaris Mem Consumption

We have Sun OS running on spark : SunOS ciniwnpr67 5.10 Generic_118833-24 sun4u sparc SUNW,Sun-Fire-V440 Having Physical RAM : Sol10box # prtconf | grep Mem Memory size: 8192 Megabytes My Top Output is : 130 processes: 129 sleeping, 1 on cpu CPU states: 98.8% idle, 0.2% user, 1.0%... (39 Replies)
Discussion started by: rajwinder
39 Replies

4. Programming

int *ptr + max possible value

From reading my C book, Im aware that the integers have a maximum value which depends on what type of processor you are using (since they use 16-bit or 32-bit instructions). Now I know pointers are very flexible, since they can reference anything, but in the case of integer pointers, can they... (4 Replies)
Discussion started by: JamesGoh
4 Replies

5. Programming

Adding a single char to a char pointer.

Hello, I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it: char* getext(char *file) { char *extension; int i, j;... (5 Replies)
Discussion started by: pallak7
5 Replies

6. AIX

Zerofault terminates and coredumps - Segmentation fault

Hi, I am using zerofault in AIX to find memory leaks for my server. zf -c <forked-server> zf -l 30 <server> <arguments> Then after some (5 mins ) it terminates core dumping and saying server exited abnormally. I could not understand the core file generated: its something like show in below... (0 Replies)
Discussion started by: vivek.gkp
0 Replies

7. Programming

concat const char * with char *

hello everybody! i have aproblem! i dont know how to concatenate const char* with char const char *buffer; char *b; sprintf(b,"result.txt"); strcat(buffer,b); thanx in advance (4 Replies)
Discussion started by: nicos
4 Replies

8. Programming

error: invalid conversion from ‘const char*’ to ‘char*’

Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially): xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’: xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’ The same error with all c++ constructors - gcc 4.4.4. If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies

9. Solaris

Cannot resolve PTR record issue

Hi guys, I am currently receiving the following output in /var/log/syslog and is occurring every second leading to /var directory being full after every 2 days. Aug 20 17:32:29 opaldn1 sendmail: r7KCOlQm002517: ruleset=check_rcpt, arg1=<postmaster@silverapp6>, relay=, reject=450 4.4.0... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

10. Programming

Invalid conversion from char* to char

Pointers are seeming to get the best of me and I get that error in my program. Here is the code #include <stdio.h> #include <stdlib.h> #include <string.h> #define REPORTHEADING1 " Employee Pay Hours Gross Tax Net\n" #define REPORTHEADING2 " Name ... (1 Reply)
Discussion started by: Plum
1 Replies
JudySL(3)						     Library Functions Manual							 JudySL(3)

NAME
JudySL macros - C library for creating and accessing a dynamic array, using a null-terminated string as an Index (associative array) SYNOPSIS
cc [flags] sourcefiles -lJudy #include <Judy.h> #define MAXLINELEN 1000000 // define maximum string length Word_t * PValue; // JudySL array element uint8_t Index[MAXLINELEN]; // string int Rc_int; // return value Word_t Rc_word; // full word return value Pvoid_t PJSLArray = (Pvoid_t) NULL; // initialize JudySL array JSLI( PValue, PJSLArray, Index); // JudySLIns() JSLD( Rc_int, PJSLArray, Index); // JudySLDel() JSLG( PValue, PJSLArray, Index); // JudySLGet() JSLFA(Rc_word, PJSLArray); // JudySLFreeArray() JSLF( PValue, PJSLArray, Index); // JudySLFirst() JSLN( PValue, PJSLArray, Index); // JudySLNext() JSLL( PValue, PJSLArray, Index); // JudySLLast() JSLP( PValue, PJSLArray, Index); // JudySLPrev() DESCRIPTION
A JudySL array is the equivalent of a sorted set of strings, each associated with a Value (word). A Value is addressed by an Index (key), which is a null-terminated character string of any length. Memory to support the array is allocated as index/value pairs are inserted, and released as index/value pairs are deleted. This is a form of associative array, where array elements are also sorted lexicographically (case-sensitive) by indexes. This could be thought of as void * JudySLArray["Toto, I don't think we're in Kansas any more"]; A JudySL array is allocated with a NULL pointer Pvoid_t PJSLArray = (Pvoid_t) NULL; As with an ordinary array, there are no duplicate indexes (strings) in a JudySL array. Using the macros described here, rather than the JudySL function calls, the default error handling sends a message to the standard error and terminates the program with exit(1). JSLI(PValue, PJSLArray, Index) // JudySLIns() Insert an Index string and Value in the JudySL array PJSLArray. 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 Index's Value. Your program must use this pointer to modify the Value, for example: *PValue = 1234; Note: JSLI() and JSLD reorganize the JudySL array. Therefore, pointers returned from previous JudySL calls become invalid and must be reacquired. JSLD(Rc_int, PJSLArray, Index) // JudySLDel() Delete the specified Index/Value pair (array element) from the JudySL array. Return Rc_int set to 1 if successful. array and it was previously inserted. Return Rc_int set to 0 if Index was not present. JSLG(PValue, PJSLArray, Index) // JudySLGet() Get the pointer to Index's Value. Return PValue pointing to Index's Value. Return PValue set to NULL if the Index was not present. JSLFA(Rc_word, PJSLArray) // JudySLFreeArray() Given a pointer to a JudySL array (PJSLArray), free the entire array (much faster than using a JSLN(), JSLD() loop.) Return Rc_word set to the number of bytes freed and PJSLArray set to NULL. JudySL Search Functions The JudySL search functions allow you to search for indexes in the array. You may search inclusively or exclusively, in either forward or reverse directions. If successful, Index is returned set to the found index, and PValue is returned set to a pointer to Index's Value. If unsuccessful, PValue is returned set to NULL, and Index contains no useful information. PValue must be tested for non-NULL prior to using Index, since a search failure is possible. Note: To accomodate all possible returns, the Index buffer must be at least as large as the largest string stored in the array. JSLF(PValue, PJSLArray, Index) // JudySLFirst() Search (inclusive) for the first index present that is equal to or greater than the passed Index string. (Start with a null string to find the first index in the array.) JSLF() is typically used to begin a sorted-order scan of the valid indexes in a JudySL array. uint8_t Index[MAXLINELEN]; strcpy (Index, ""); JSLF(PValue, PJSLArray, Index); JSLN(PValue, PJSLArray, Index) // JudySLNext() Search (exclusive) for the next index present that is greater than the passed Index string. JSLN() is typically used to continue a sorted- order scan of the valid indexes in a JudySL array, or to locate a "neighbor" of a given index. JSLL(PValue, PJSLArray, Index) // JudySLLast() Search (inclusive) for the last index present that is equal to or less than the passed Index string. (Start with a maximum-valued string to look up the last index in the array, such as a max-length string of 0xff bytes.) JSLL() is typically used to begin a reverse-sorted- order scan of the valid indexes in a JudySL array. JSLP(PValue, PJSLArray, Index) // JudySLPrev() Search (exclusive) for the previous index present that is less than the passed Index string. JSLP() is typically used to continue a reverse-sorted-order scan of the valid indexes in a JudySL array, or to locate a "neighbor" of a given index. ERRORS
: See: Judy_3.htm#ERRORS EXAMPLE of a string sort routine #include <stdio.h> #include <Judy.h> #define MAXLINE 1000000 // max string (line) length uint8_t Index[MAXLINE]; // string to insert int // Usage: JudySort < file_to_sort main() { Pvoid_t PJArray = (PWord_t)NULL; // Judy array. PWord_t PValue; // Judy array element. Word_t Bytes; // size of JudySL array. while (fgets(Index, MAXLINE, stdin) != (char *)NULL) { JSLI(PValue, PJArray, Index); // store string into array if (PValue == PJERR) // if out of memory? { // so do something printf("Malloc failed -- get more ram "); exit(1); } ++(*PValue); // count instances of string } Index[0] = ''; // start with smallest string. JSLF(PValue, PJArray, Index); // get first string while (PValue != NULL) { while ((*PValue)--) // print duplicates printf("%s", Index); JSLN(PValue, PJArray, Index); // get next string } JSLFA(Bytes, PJArray); // free array fprintf(stderr, "The JudySL array used %lu bytes of memory ", Bytes); return (0); } AUTHOR
Judy was invented by Doug Baskins and implemented by Hewlett-Packard. SEE ALSO
Judy(3), Judy1(3), JudyL(3), JudyHS(3), malloc(), the Judy website, http://judy.sourceforge.net, for further information and Application Notes. JudySL(3)
All times are GMT -4. The time now is 04:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy