Sponsored Content
Top Forums Programming Segmentation fault when I pass a char pointer to a function in C. Post 303016280 by Corona688 on Monday 23rd of April 2018 06:09:15 PM
Old 04-23-2018
Quote:
Originally Posted by dryden
Yes, interesting. So because that array stores actual memory on the stack, you cannot change what it points to, hmmmm. I thought arrays were pointers, until I tried to assign an array (pointer) to something else ;-). [I mean the reverse, assign something else to that array].
It's implicitly a pointer, implemented as one internally, but the same way you're not allowed to change a string's contents, you're not allowed to change its value. Hardcoded.
 

10 More Discussions You Might Find Interesting

1. AIX

Segmentation fault

I am tring to install Lotus Domino/Notes 5.0.5 on a AIX 4.3.3 server. I go to run the cdrom/ibmpow/install and I get the following error. Lotus Notes for Unix Install Program --------------------------------------------- ./install: 10088 Segmentation fault This had Lotus Notes installed... (1 Reply)
Discussion started by: jshaulis
1 Replies

2. 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

3. Programming

segmentation fault

If I do this. Assume struct life { char *nolife; } struct life **life; // malloc initialization & everything if(life->nolife == 0) Would I get error at life->nolife if it is equal to 0. wrong accession? (3 Replies)
Discussion started by: joey
3 Replies

4. Programming

pass a pointer-to-pointer, or return a pointer?

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)
Discussion started by: aaronwong
11 Replies

5. Programming

segmentation fault in fwrite function

Hi, my code is written in proC and it is in UNIX(AIX).I have written a small code for writing data into a binary file,but while writing my program is giving core dump. Here Is my code---- fpWriteFile = fopen(WriteFileName,"wb+"); CHAR *recvgen; recvgen = (char... (7 Replies)
Discussion started by: ajaysahoo
7 Replies

6. Programming

C++ segmentation fault while checking for null pointer

void disptree(node *ptr) { if ((ptr->left) !=NULL) disptree(ptr->left); cout<<"Position:"<<ptr->pos<<" Data:"<<ptr->data<<endl; if ((ptr->right)!=NULL; disptree(ptr->right); } i'm getting a segmentation fault at the red line. i cannot understand what's the problem.... (3 Replies)
Discussion started by: vijaymrt
3 Replies

7. Programming

segmentation fault while returning from function.

I am working on the application in which I have to fetch values from the database and paste in url and send it to portal. table=get_result("SELECT serialno,cas,Mode,FLC,TLC,location,CompName,CompCode,FG,FC,DispNo,TruckNo,LWbill,RRGPN,INVNO,DCN,RQTY,DQTY,SQTY,DDATE,RDATE,SDATE,TTIME FROM... (1 Reply)
Discussion started by: er.rohan88
1 Replies

8. 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

9. Shell Programming and Scripting

Segmentation fault in function call, shell script

I am getting Segmentation fault at below function call in my script: get_x() { sqlplus -s / <<end | grep KEEP | sed 's/KEEP//;s///g' select 'KEEP' ,table_name from all_synonyms where upper(synonym_name)= '$1'; exit end x=$(get_x $1) echo " SQL OUTPUT IS :: $x" } I am getting output of... (1 Reply)
Discussion started by: IB_88
1 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
XmRepTypeRegister(library call) 										   XmRepTypeRegister(library call)

NAME
XmRepTypeRegister -- A representation type manager function that registers a representation type resource SYNOPSIS
#include <Xm/RepType.h> XmRepTypeId XmRepTypeRegister( String rep_type, String *value_names, unsigned char *values, unsigned char num_values); DESCRIPTION
XmRepTypeRegister registers a representation type resource with the representation type manager. All features of the representation type management facility become available for the specified representation type. The function installs a forward type converter to convert string values to numerical representation type values. When the values argument is NULL, consecutive numerical values are assumed. The order of the strings in the value_names array determines the numerical values for the resource. For example, the first value name is 0 (zero); the second value name is 1; and so on. If it is non-NULL, the values argument can be used to assign values to representation types that have nonconsecutive values or have dupli- cate names for the same value. Representation types registered in this manner will consume additional storage and will be slightly slower than representation types with consecutive values. A representation type can only be registered once; if the same representation type name is registered more than once, the behavior is unde- fined. The function XmRepTypeAddReverse installs a reverse converter for a registered representation type. The reverse converter takes a represen- tation type numerical value and returns the corresponding string value. If the list of numerical values for a representation type contains duplicate values, the reverse converter uses the first name in the value_names list that matches the specified numeric value. For example, if a value_names array has cancel, proceed, and abort, and the corresponding values array contains 0, 1, and 0, the reverse converter will return cancel instead of abort for an input value of 0. rep_type Specifies the representation type name. value_names Specifies a pointer to an array of value names associated with the representation type. A value name is specified in lowercase characters without an Xm prefix. Words within a name are separated with underscores. values Specifies a pointer to an array of values associated with the representation type. A value in this array is associated with the value name in the corresponding position of the value_names array. num_values Specifies the number of entries in the value_names and values arrays. RETURN
Returns the identification number for the specified representation type. RELATED
XmRepTypeAddReverse(3), XmRepTypeGetId(3), XmRepTypeGetNameList(3), XmRepTypeGetRecord(3), XmRepTypeGetRegistered(3), and XmRepTypeValid- Value(3). XmRepTypeRegister(library call)
All times are GMT -4. The time now is 01:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy