Re: How Globals is handle in C.
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 01 Feb 2006 19:31:23 GMT
"sant" <santoshnayak9@xxxxxxxxx> writes:
> "Hello World" string will be stored in the Initialized data segment. In
> that it is stored in Read Only Memory.
>
> temp will store the starting address of this Read Only string. I think
> temp is stored in stack if you have not declared it as global.
As we've said here hundreds or thousands of times, *please* provide
some context when you post a followup. Not everyone can easily see
the article to which you're replying. group.google.com makes this
gratuitously difficult, but there is a workaround. See
<http://cfaj.freeshell.org/google/> for details.
The C language says nothing about an "initialized data segment" or
"read only memory". It refers to three distinct "storage durations":
static, automatic, and allocated.
A string literal may or may not be stored in some kind of read-only
memory. A portable program can't tell the difference, since any
attempt to modify a string literal invokes undefined behavior.
Again, *please* read <http://cfaj.freeshell.org/google/>.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
Relevant Pages
- Re: Importing data from a textfile
... I don't know how many different types of string there are beforehand. ... temp = textscan; ... You can use it to break an arbitrarily long comma delimited list into a cell array of parts, then operate at will on the parts. ... Another think you might experiment with to speed things up is to read the entire file into memory with the 'fileread' command, and then use regex and cellfun to search the contents in memory. ... (comp.soft-sys.matlab) - Re: MASD syntax to load the current address in C.A at runtime
... so my memory on A=PC is not as good. ... CODE object, the CRC on the CODE object will change. ... easier to store individual pieces as the time string was built. ... (comp.sys.hp48) - Re: Fast string operations
... Looping: I thought looping over arrays in managed code was "slow" ... array handling and such. ... The problem with TrimHelper is that it always returns a new string instance. ... The customer perceives this as a memory leak. ... (microsoft.public.dotnet.languages.csharp) - Re: Discovering variable types...
... >- but I suppose MS expect us to use wrappers ... memory allocations for your variables from disk as well. ... >They most certainly are of fixed size, changing the size of a String ... >>me to keep buffer size and current postion right in the memory block. ... (comp.lang.pascal.delphi.misc) - Re: Optimize
... if you use it like me to get 'the next string ptr' in addition. ... | |mov ebx eax;dw aligned strings are faster ... | Would it be enough to touch each 16th bytes in the 64K memory area ... Cache-line size is fixed, my AMD got 64 bytes per line. ... (alt.lang.asm) |
|