Pointer and address


 
Thread Tools Search this Thread
Top Forums Programming Pointer and address
# 15  
Old 05-09-2013
One needs to know 1 layer too much to know you know enough. It is great that the compiler and linker take care of the alllocation of all the bits, but you should know that 'char *x;' makes one pointer x on the local stack not initialized, 'char *x = "123";' makes a writable initialized character array of 4 bytes on the heap and one pointer x on the stack initialized to point to that array, but 'char x[] = "123" ;' creates a 4 character array on the stack and x is a pointer to it, not stored in run time memory, just known to the compiler. Some things are compile time only, and some are run time.

JAVA and I suppose parts of C# have automatic housekeeping so junk createdon the heap is recycled when all references to it are released. So, 'String x = "123" ;' creates a local String Class reference x and an immutable String object on the heap holding the three characters. If later in the code flow you say 'x = "234" ;', the last reference to "123" is destroyed, so it can be garbage collected, and a new String Object is created on the heap.

In C/C++, if you rewrite your char*, the old char[] is lost in a memory leak.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

C program to detect duplicate ip address if any after assigning ip address to ethernet interface

Hi , Could someone let me know how to detect duplicate ip address after assigning ip address to ethernet interface using c program (3 Replies)
Discussion started by: Gopi Krishna P
3 Replies

2. UNIX for Dummies Questions & Answers

Printing pointer address

How can I print the memory address of a pointer using printf (or any other STDOUT functions?). I see in Linux its %p but not in unix, help? thanks (5 Replies)
Discussion started by: perleo
5 Replies

3. IP Networking

Tracing a MAC address to IP address: Solaris

Hi there I lost connectivity to one of our remote systems and when I checked the messages log I found the following: Aug 10 23:42:34 host xntpd: time reset (step) 1.681729 s Aug 16 13:20:51 host ip: WARNING: node "mac address" is using our IP address x.x.x.x on aggr1 Aug 16 13:20:51 host... (9 Replies)
Discussion started by: notreallyhere
9 Replies

4. UNIX for Dummies Questions & Answers

Panic kernal-mode address fault on user address 0x14

:) Firstly Hi all!!, im NEW!! and on here hoping that someone might be able to offer me some help... i have a server that keeps crashing every few days with the error message: PANIC KERNAL-MODE ADDRESS FAULT ON USER ADDRESS 0X14 KERNAL PAGE FAULT FROM (CS:EIP)=(100:EF71B5BD) EAX=EF822000... (10 Replies)
Discussion started by: Twix
10 Replies

5. Shell Programming and Scripting

ksh - how to list all ip address between 2 ip address

Trying to do a ksh script that needs to list all ip address between ip address a and b .. ie. Ip address A=192.168.1.200 Ip address B=192.168.2.15 So the subnet changes from 1 to 2 but I want to list all possible ip addresses between the 2.. Which would be: 192.168.1.200... (4 Replies)
Discussion started by: frustrated1
4 Replies

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

7. Programming

address of pointer

Hi i'm new to c programming and i'm trying to change the address of a pointer/variable but i can't seem to get it right, I have this char heap; char *firstFree = heap; char *allocMem( int size ) { void *malloc(size_t sizeofint); /*allocate space for an array with size... (19 Replies)
Discussion started by: Poison Ivy
19 Replies

8. Programming

A Pointer to non-Virtual Address, and All of my Hard drive

How do I get a pointer to any 32 bit address on my hard drive, in which I then could read that memory or write to that memory address? And, while the subject is on, how do get a 32 bit pointer in RAM also, in which I can do the same? I'm using C and Objective-C with gcc on an iBook G4. A... (9 Replies)
Discussion started by: xcoder66
9 Replies

9. IP Networking

How to Achive IP address through MAC(Ethernet) address

Hi sir, i want to make such programe which takes MAC(Ethernet) address of any host & give me its IP address....... but i'm nt getting that how i can pass the MAC address to Frame........ Please give me an idea for making such program... Thanks & regards Krishna (3 Replies)
Discussion started by: krishnacins
3 Replies

10. UNIX for Dummies Questions & Answers

network address and broadcast address?

say I have a IP address which is 10.0.0.12, and subnet mask is 255.255.255.240, what is the network address and what is the broadcast address which host lives on? And could you explain how to get the answer? thanx in advance! (7 Replies)
Discussion started by: pnxi
7 Replies
Login or Register to Ask a Question
Tcl_ExprLongObj(3)					      Tcl Library Procedures						Tcl_ExprLongObj(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprObj - evaluate an expression SYNOPSIS
#include <tcl.h> int Tcl_ExprLongObj(interp, objPtr, longPtr) int Tcl_ExprDoubleObj(interp, objPtr, doublePtr) int Tcl_ExprBooleanObj(interp, objPtr, booleanPtr) int Tcl_ExprObj(interp, objPtr, resultPtrPtr) ARGUMENTS
Tcl_Interp *interp (in) Interpreter in whose context to evaluate string or objPtr. Tcl_Obj *objPtr (in) Pointer to an object containing the expression to evaluate. long *longPtr (out) Pointer to location in which to store the integer value of the expression. int *doublePtr (out) Pointer to location in which to store the floating-point value of the expression. int *booleanPtr (out) Pointer to location in which to store the 0/1 boolean value of the expression. Tcl_Obj **resultPtrPtr (out) Pointer to location in which to store a pointer to the object that is the result of the expression. _________________________________________________________________ DESCRIPTION
These four procedures all evaluate an expression, returning the result in one of four different forms. The expression is given by the objPtr argument, and it can have any of the forms accepted by the expr command. The interp argument refers to an interpreter used to evaluate the expression (e.g. for variables and nested Tcl commands) and to return error information. For all of these procedures the return value is a standard Tcl result: TCL_OK means the expression was successfully evaluated, and TCL_ERROR means that an error occurred while evaluating the expression. If TCL_ERROR is returned, then a message describing the error can be retrieved using Tcl_GetObjResult. If an error occurs while executing a Tcl command embedded in the expression then that error will be returned. If the expression is successfully evaluated, then its value is returned in one of four forms, depending on which procedure is invoked. Tcl_ExprLongObj stores an integer value at *longPtr. If the expression's actual value is a floating-point number, then it is truncated to an integer. If the expression's actual value is a non-numeric string then an error is returned. Tcl_ExprDoubleObj stores a floating-point value at *doublePtr. If the expression's actual value is an integer, it is converted to float- ing-point. If the expression's actual value is a non-numeric string then an error is returned. Tcl_ExprBooleanObj stores a 0/1 integer value at *booleanPtr. If the expression's actual value is an integer or floating-point number, then they store 0 at *booleanPtr if the value was zero and 1 otherwise. If the expression's actual value is a non-numeric string then it must be one of the values accepted by Tcl_GetBoolean such as ``yes'' or ``no'', or else an error occurs. If Tcl_ExprObj successfully evaluates the expression, it stores a pointer to the Tcl object containing the expression's value at *resultP- trPtr. In this case, the caller is responsible for calling Tcl_DecrRefCount to decrement the object's reference count when it is finished with the object. SEE ALSO
Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString, Tcl_GetObjResult KEYWORDS
boolean, double, evaluate, expression, integer, object, string Tcl 8.0 Tcl_ExprLongObj(3)