Sponsored Content
Full Discussion: Symbol table of a C program
Top Forums Programming Symbol table of a C program Post 302368657 by fpmurphy on Thursday 5th of November 2009 09:29:35 AM
Old 11-05-2009
MrUser, your code is problematic. Consider the following 2 statements:
Code:
char p[] = "test";
char *p = "test";

In the first statement, a mutable (modifiable or non-constant) string p is declared as an array of character and initialized with the string "test". The size of array p is 5 bytes including a null terminator. The result of *p = 'T' is defined and works as expected.

In the second statement an immutable (AKA constant) string litteral is declared and the base address of the memory where the compiler stores the string litteral is assigned to the pointer variable p. In this case, the result of *p = 'T' is undefined as you found out.

When you want a mutable string, i.e. a string which can be modified, use initialization instead of assignment.
 

10 More Discussions You Might Find Interesting

1. Programming

no symbol table

Hi@all, I try to compile c code on hpux 11.11 pa-risc 2 with gcc (32bit). I compile with the option -g, so that I get the symbol table, but it is not available. Does someone knows something on this? thx (2 Replies)
Discussion started by: Dom_Cyrus
2 Replies

2. Programming

how to view symbol table in unix

hi , How to view the contents of a "c" program symbol table information in unix. (1 Reply)
Discussion started by: saravanan_nitt
1 Replies

3. Linux

Reading ELF file Symbol table of C++ program

Folks, I have some program(Test.cpp) as follows, #include<iostream> class Abc { private: int _theVar; public : int printVar(); }; int Abc :: printVar() { _theVar=10; } main() { Abc _t; (0 Replies)
Discussion started by: vinod_chitrali
0 Replies

4. Programming

Reading ELF file Symbol table of C++ program

Folks, I have some program(Test.cpp) as follows, #include<iostream> class Abc { private: int _theVar; public : int printVar(); }; int Abc :: printVar() { _theVar=10; } main() { Abc _t; (2 Replies)
Discussion started by: vinod_chitrali
2 Replies

5. Solaris

/usr/lib/passwdutil.so.1: symbol __nsl_fgetspent_r: referenced symbol not found

deleteing post (0 Replies)
Discussion started by: dshakey
0 Replies

6. Programming

C program to display a busy symbol while processing

Hi I was wondering how can a c program will be implemented which will display a symbol while calculating something. for example : program should display some charters like /\/\ while calculating. At least provide some pointers thanks (4 Replies)
Discussion started by: rakeshkumar
4 Replies

7. UNIX for Dummies Questions & Answers

Creating a condensed table from a pre-existing table in putty

Hello, I'm working with putty on Windows 7 professional and I'd like to know if there's a way to gather specific lines from a pre-existing table and make a new table with that information. More specifically, I'd like the program to look at a specific column, say column N, and see if any of the... (5 Replies)
Discussion started by: Deedee393
5 Replies

8. Shell Programming and Scripting

Build a table from a list by comparing existing table entries

I am new to this shell scripting.... I have a file which contains list of users. This files get updated when new user comes into the system. I want to create script which will give a table containing unique list of users. When I say unique, it means script should match table while parsing... (3 Replies)
Discussion started by: dchavan1901
3 Replies

9. Web Development

Getting Rid of Annoying Bootstrap Table Borders and Wayward Table Lines

Bootstrap is great; but we have had some issues with Bootstrapped <tables> (and legacy <fieldset> elements) showing annoying, wayward lines. I solved that problem today with this simple jQuery in the footer: <script> $(function(){ $('tr, td, fieldset,... (0 Replies)
Discussion started by: Neo
0 Replies

10. Programming

Search the symbol table of a child process

Hi, I am a newbie in Linux land, and I have a question about programming parent/child process interaction: How do I search the value of a symbol in the child process? Is it possible? I am doing a fork() and execve() to spawn any child possible, and I need something on the parent side to... (12 Replies)
Discussion started by: alphakili
12 Replies
PROP_STRING(3)						   BSD Library Functions Manual 					    PROP_STRING(3)

NAME
prop_string, prop_string_create, prop_string_create_cstring, prop_string_create_cstring_nocopy, prop_string_copy, prop_string_copy_mutable, prop_string_size, prop_string_mutable, prop_string_cstring, prop_string_cstring_nocopy, prop_string_append, prop_string_append_cstring, prop_string_equals, prop_string_equals_cstring -- string value property object LIBRARY
Property Container Object Library (libprop, -lprop) SYNOPSIS
#include <prop/proplib.h> prop_string_t prop_string_create(void); prop_string_t prop_string_create_cstring(const char *cstring); prop_string_t prop_string_create_cstring_nocopy(const char *cstring); prop_string_t prop_string_copy(prop_string_t string); prop_string_t prop_string_copy_mutable(prop_string_t string); size_t prop_string_size(prop_string_t string); bool prop_string_mutable(prop_string_t string); char * prop_string_cstring(prop_string_t string); const char * prop_string_cstring_nocopy(prop_string_t string); bool prop_string_append(prop_string_t str1, prop_string_t str2); bool prop_string_append_cstring(prop_string_t string, const char *cstring); bool prop_string_equals(prop_string_t str1, prop_string_t str2); bool prop_string_equals_cstring(prop_string_t string, const char *cstring); DESCRIPTION
The prop_string family of functions operate on a string value property object type. prop_string_create(void) Create an empty mutable string. Returns NULL on failure. prop_string_create_cstring(const char *cstring) Create a mutable string that contains a copy of cstring. Returns NULL on failure. prop_string_create_cstring_nocopy(const char *cstring) Create an immutable string that contains a reference to cstring. Returns NULL on failure. prop_string_copy(prop_string_t string) Copy a string. If the string being copied is an immutable external C string reference, then the copy is also immutable and references the same external C string. Returns NULL on failure. prop_string_copy_mutable(prop_string_t string) Copy a string, always creating a mutable copy. Returns NULL on failure. prop_string_size(prop_string_t string) Returns the size of the string, not including the terminating NUL. If the supplied object isn't a string, zero is returned. prop_string_mutable(prop_string_t string) Returns true if the string is mutable. If the supplied object isn't a string, false is returned. prop_string_cstring(prop_string_t string) Returns a copy of the string's contents as a C string. The caller is responsible for freeing the returned buffer. In user space, the buffer is allocated using malloc(3). In the kernel, the buffer is allocated using malloc(9) using the malloc type M_TEMP. Returns NULL on failure. prop_string_cstring_nocopy(prop_string_t string) Returns an immutable reference to the contents of the string as a C string. If the supplied object isn't a string, NULL is returned. prop_string_append(prop_string_t str1, prop_string_t str2) Append the contents of str2 to str1, which must be mutable. Returns true upon success and false otherwise. prop_string_append_cstring(prop_string_t string, const char *cstring) Append the C string cstring to string, which must be mutable. Returns true upon success and false otherwise. prop_string_equals(prop_string_t str1, prop_string_t str2) Returns true if the two string objects are equivalent. prop_string_equals_cstring(prop_string_t string, const char *cstring) Returns true if the string's value is equivalent to cstring. SEE ALSO
prop_array(3), prop_bool(3), prop_data(3), prop_dictionary(3), prop_number(3), prop_object(3), proplib(3) HISTORY
The proplib property container object library first appeared in NetBSD 4.0. BSD
January 21, 2008 BSD
All times are GMT -4. The time now is 08:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy