Sponsored Content
Top Forums Programming segmentation fault for extern Post 302439079 by Corona688 on Wednesday 21st of July 2010 04:59:50 PM
Old 07-21-2010
More specifically: A pointer is an integer variable that holds a memory address. It takes a small and fixed number of bytes. You're using it to point to memory stored elsewhere.

When you define it as an array, you're telling it that all the memory for that array is stored at the memory address of the pointer, not the memory address stored in the pointer. It expects 80 bytes of data right there, not where it points to.

You could do "extern int arr[]" perhaps. That way you're telling it it's an array, as you'd expect, but the size at least wouldn't have to be known.
 

10 More Discussions You Might Find Interesting

1. Programming

segmentation fault

sometimes for this code i get a segmentation fault for codes llike this : int main{ int * a= 0; int b; a = (int*)malloc(sizeof(int)); ///some code using these variable but no freeing of a if(a){ free(a); a = 0; } return... (3 Replies)
Discussion started by: wojtyla
3 Replies

2. UNIX for Dummies Questions & Answers

Segmentation Fault

hello all, I tried a program on an array to intialise array elements from the standard input device.it is an integer array of 5 elements.but after entering the 4th element it throws a message called "Segmentation Fault" and returns to the command prompt without asking for the 5th element. ... (3 Replies)
Discussion started by: compbug
3 Replies

3. AIX

Segmentation fault

Hi , During execution a backup binary i get following error "Program error 11 (Segmentation fault), saving core file in '/usr/datatools" Riyaz (2 Replies)
Discussion started by: rshaikh
2 Replies

4. Linux

Segmentation fault

Hi, on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error : RMAN> delete obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 using channel ORA_DISK_1 Segmentation fault What does it mean ? And the solution ? Many thanks. (0 Replies)
Discussion started by: big123456
0 Replies

5. Programming

segmentation fault

Hi, I am having this segmentation fault not in the following program, bt. in my lab program . My lab program is horrible long so cannot post it here bt. I am using the following logic in my program which is giving the segmentation fault. Bt. if I run this sample program as it is it dosen't give... (3 Replies)
Discussion started by: mind@work
3 Replies

6. Programming

Segmentation fault in C

i have this code int already_there(char *client_names, char *username) { int i; for(i = 0; i<NUM; i++) { printf("HERE\n"); if (strcmp(client_names, username)==0) return(1); } return(0); } and i get a segmentation fault, whats wrong here? (7 Replies)
Discussion started by: omega666
7 Replies

7. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

8. Solaris

Segmentation fault

Hi Guys, I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error: "Segmentation fault" Can someone please help me resolve this? Thanks alot (2 Replies)
Discussion started by: cjashu
2 Replies

9. Programming

Segmentation fault

I keep getting this fault on a lot of the codes I write, I'm not exactly sure why so I'd really appreciate it if someone could explain the idea to me. For example this code #include <stdio.h> main() { unsigned long a=0; unsigned long b=0; int z; { printf("Enter two... (2 Replies)
Discussion started by: sizzler786
2 Replies

10. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies
xdr_complex(3N) 														   xdr_complex(3N)

NAME
xdr_complex, xdr_array, xdr_bytes, xdr_opaque, xdr_pointer, xdr_reference, xdr_string, xdr_union, xdr_vector, xdr_wrapstring - library rou- tines for external data representation SYNOPSIS
#include <rpc/xdr.h> DESCRIPTION
XDR library routines allow C programmers to describe complex data structures in a machine-independent fashion. Protocols such as remote procedure calls (RPC) use these routines to describe the format of the data. These routines are the XDR library routines for complex data structures. They require the creation of XDR stream (see xdr_create(3N)). Routines See rpc(3N) for the definition of the data structure. Note that any buffers passed to the XDR routines must be properly aligned. It is suggested that be used to allocate these buffers or that the programmer insure that the buffer address is divisible evenly by four. translates between variable-length arrays and their corresponding external representations. The parameter arrp is the address of the pointer to the array, while sizep is the address of the element count of the array; this element count cannot exceed maxsize. The parameter elsize is the size of each of the array's elements, and elproc is an XDR routine that translates between the array elements' C form and their external representa- tion. If is null when decoding, allocates memory and points to it. This routine returns if it succeeds, otherwise. translates between counted byte strings and their external representations. The parameter sp is the address of the string pointer. The length of the string is located at address sizep; strings cannot be longer than maxsize. If is null when decoding, allocates memory and points to it. This routine returns if it succeeds, otherwise. translates between fixed size opaque data and its external representation. The parameter cp is the address of the opaque object, and cnt is its size in bytes. This routine returns if it succeeds, otherwise. Like except that it serializes pointers, whereas does not. Thus, can represent recursive data structures, such as binary trees or linked lists. If is null when decoding, allocates memory and points to it. provides pointer chasing within structures. The parameter pp is the address of the pointer; size is the the structure that *pp points to; and proc is an XDR procedure that translates the structure between its C form and its external representation. If is null when decoding, allocates memory and points to it. This routine returns if it succeeds, otherwise. Warning: this routine does not understand pointers. Use instead. translates between C strings and their corresponding external representations. Strings cannot be longer than maxsize. Note: sp is the address of the string's pointer. If is null when decoding, allocates memory and points to it. This routine returns if it succeeds, otherwise. Note: can be used to send an empty string (""), but not a NULL string. translates between a discriminated C and its corresponding external representation. It first translates the discriminant of the union located at dscmp. This discrimi- nant is always an Next the union located at unp is translated. The parameter choices is a pointer to an array of structures. Each structure contains an ordered pair of [value,proc]. If the union's discriminant is equal to the associated value, then the proc is called to translate the union. The end of the structure array is denoted by a routine of value If the discriminant is not found in the choices array, then the defaultarm procedure is called (if it is not Returns if it succeeds, otherwise. translates between fixed-length arrays and their corresponding external representations. The parameter arrp is the address of the pointer to the array, while size is the element count of the array. The parameter elsize is the each of the array's elements, and elproc is an XDR routine that translates between the array elements' C form and their external representation. This routine returns if it succeeds, otherwise. A routine that calls where maxuint is the maximum value of an unsigned integer. Many routines, such as and take a function pointer of type which takes two arguments. one of the most frequently used routines, requires three arguments, while only requires two. For these routines, is desirable. This routine returns if it succeeds, other- wise. MULTITHREAD USAGE
Thread Safe: Yes Cancel Safe: Yes Fork Safe: No Async-cancel Safe: No Async-signal Safe: No These functions can be called safely in a multithreaded environment. They may be cancellation points in that they call functions that are cancel points. In a multithreaded environment, these functions are not safe to be called by a child process after and before These functions should not be called by a multithreaded application that support asynchronous cancellation or asynchronous signals. SEE ALSO
rpc(3N), xdr_admin(3N), xdr_create(3N), xdr_simple(3N). xdr_complex(3N)
All times are GMT -4. The time now is 01:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy