Skip to main content

Timeline for Legitimate usage of char*

Current License: CC BY-SA 3.0

9 events
when toggle format what by license comment
Aug 11, 2015 at 22:24 comment added David K @barakmanos OK, I give up. You're right, of course. The program could be compiled into a FPGA for all we know. So I removed "at run time" from the answer. The rest of this argument seems to be about concerns that (I think) are beyond anything the OP would want to know at this time
Aug 11, 2015 at 22:19 comment added David K @Potatoswatter Thanks, I had momentarily considered the const, but omitted it for some reason. It is a better example as a const string (with corresponding changes to what the programmer can or can't do).
Aug 11, 2015 at 22:15 history edited David K CC BY-SA 3.0
incorporated comments
Aug 11, 2015 at 21:58 comment added Potatoswatter More similar to const char s_buffer[10] = "my String";
Aug 11, 2015 at 21:55 comment added barak manos locations in (virtual) memory actually get "allocated" when the program is loaded - that's an OS issue, which is unrelated to (and independent of) the program. In other words, the program "knows" nothing about it. As far as it "concerns", that string is allocated at the RO data section of the executable image. Of course, the actual (physical) address of that string maybe different every time the OS creates a process and loads it into memory. But it's like saying that the program may be running at a different place around the world, depending on where your computer is located.
Aug 11, 2015 at 21:51 history edited David K CC BY-SA 3.0
Distinguish compile time from runtime actions
Aug 11, 2015 at 21:49 comment added David K @barakmanos I had in mind that the locations in (virtual) memory actually get "allocated" when the program is loaded. However, a lot of what happens in the first three bullets is decided at compile time, whereas corresponding actions for the second example might only be decided when the program actually runs.
Aug 11, 2015 at 21:45 comment added barak manos The first 3 bullets most definitely take place before runtime, i.e., during compilation. The 4th bullet should also take place during compilation, assuming a decent compiler is in use (since the address of the constant string is well known at this point). Perhaps you meant to say "here's what your compiler will do at run time" (its own runtime)...
Aug 11, 2015 at 21:37 history answered David K CC BY-SA 3.0