Click here to Skip to main content
16,010,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Memory related issues Pin
rajeevktripathi10-Apr-06 18:58
rajeevktripathi10-Apr-06 18:58 
AnswerRe: Memory related issues Pin
Ryan Binns10-Apr-06 20:09
Ryan Binns10-Apr-06 20:09 
AnswerRe: Memory related issues Pin
kakan10-Apr-06 19:03
professionalkakan10-Apr-06 19:03 
GeneralRe: Memory related issues Pin
normanS10-Apr-06 19:49
normanS10-Apr-06 19:49 
GeneralRe: Memory related issues Pin
Ryan Binns10-Apr-06 20:07
Ryan Binns10-Apr-06 20:07 
GeneralRe: Memory related issues Pin
normanS11-Apr-06 0:39
normanS11-Apr-06 0:39 
GeneralRe: Memory related issues Pin
Ryan Binns11-Apr-06 0:47
Ryan Binns11-Apr-06 0:47 
AnswerRe: Memory related issues Pin
Stephen Hewitt10-Apr-06 21:23
Stephen Hewitt10-Apr-06 21:23 
rajeevktripathi wrote:
1) As we know that if a variable is declered in a file (Let .c file) then we can access this variable from any other .c file by using "extern" key word...... Now Question is where this extern variable is stored in memory.

 
  The extern keyword tells the compiler that the variable is defined in another compilation unit and so no new space is needed for it - It just makes a variable from one compilation unit available in another. NOTE: It is ignored if the variable is initialized.

rajeevktripathi wrote:
2) Is there any way to make this sure that if any variable is declared in some .c file then any other file can not access this variable.

 
  Two popular ways to do this (in C++):
1. The preferred way is to enclose it in an anonymous namespace. i.e.
namespace
{
     // Put stuff here.
}

2. The old deprecated way is to put the keyword static before it.

In C only the 2nd option is available.

rajeevktripathi wrote:

3) where the variables are stored while execution of program (RAM, or Hard disk, or CPU Registers)..

 
  The simple answer is RAM - Which is more or less correct. However if you want to knit-pick it is more complicated than this:
 - Windows has virtual memory thus the memory that stores the variable could be paged out in which case it is stored on disk until it is paged back into RAM again.
 - The compiler may use registers. Many things effect if this is the case, such as what optimizations are used, usage of the keyword register, the structure of the code and the "intelligence" of the compiler.


Steve
Questionregarding MapViewOfFile Pin
namaskaaram10-Apr-06 18:30
namaskaaram10-Apr-06 18:30 
AnswerRe: regarding MapViewOfFile Pin
Ryan Binns10-Apr-06 18:47
Ryan Binns10-Apr-06 18:47 
GeneralRe: regarding MapViewOfFile Pin
Blake Miller12-Apr-06 5:07
Blake Miller12-Apr-06 5:07 
GeneralRe: regarding MapViewOfFile Pin
Ryan Binns12-Apr-06 13:50
Ryan Binns12-Apr-06 13:50 
QuestionLinkage C Pin
mostafa_pasha10-Apr-06 17:58
mostafa_pasha10-Apr-06 17:58 
Questiondebug assertion failed Pin
mrby12310-Apr-06 17:19
mrby12310-Apr-06 17:19 
AnswerRe: debug assertion failed Pin
lastgen10-Apr-06 17:55
lastgen10-Apr-06 17:55 
GeneralRe: debug assertion failed Pin
mrby12310-Apr-06 18:04
mrby12310-Apr-06 18:04 
QuestionHow to store a Binary value in a variable? Pin
CodeVarma10-Apr-06 17:05
CodeVarma10-Apr-06 17:05 
AnswerRe: How to store a Binary value in a variable? Pin
Ryan Binns10-Apr-06 18:21
Ryan Binns10-Apr-06 18:21 
QuestionVariable Help Pin
borono10-Apr-06 14:14
borono10-Apr-06 14:14 
AnswerRe: Variable Help Pin
Joshua Quick10-Apr-06 15:43
Joshua Quick10-Apr-06 15:43 
GeneralRe: Variable Help Pin
borono10-Apr-06 17:30
borono10-Apr-06 17:30 
AnswerRe: Variable Help Pin
Joshua Quick10-Apr-06 17:49
Joshua Quick10-Apr-06 17:49 
GeneralRe: Variable Help Pin
borono11-Apr-06 10:43
borono11-Apr-06 10:43 
GeneralRe: Variable Help Pin
Joshua Quick11-Apr-06 12:05
Joshua Quick11-Apr-06 12:05 
QuestionCTreeCtrl checkboxes Pin
CodeGoose10-Apr-06 11:34
CodeGoose10-Apr-06 11:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.