Click here to Skip to main content
15,905,782 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get all controls of current dialog? Pin
Hamid_RT18-Apr-08 5:14
Hamid_RT18-Apr-08 5:14 
GeneralRe: How to get all controls of current dialog? Pin
mehmetned21-Apr-08 2:58
mehmetned21-Apr-08 2:58 
GeneralRe: How to get all controls of current dialog? Pin
Hamid_RT21-Apr-08 19:27
Hamid_RT21-Apr-08 19:27 
GeneralRe: How to get all controls of current dialog? Pin
ThatsAlok30-Jun-09 23:28
ThatsAlok30-Jun-09 23:28 
GeneralBriefcase shell context menu Pin
john563218-Apr-08 3:53
john563218-Apr-08 3:53 
GeneralRe: Briefcase shell context menu Pin
Iain Clarke, Warrior Programmer18-Apr-08 4:05
Iain Clarke, Warrior Programmer18-Apr-08 4:05 
GeneralWH_CBT Hook - Transparent Menues Pin
Rahvin18-Apr-08 3:36
Rahvin18-Apr-08 3:36 
Questionconst issue... [modified] Pin
paulstandard18-Apr-08 3:29
paulstandard18-Apr-08 3:29 
Hi,
I was trying to find some way to change a const value using pointers (just for the hell of it).
I guessed const is a compile time restriction and not a runtime one.
I came across this.
The code compiles and runs without any error.
It displays 12 20, even though the code suggests p and y must be having a value of 20.
I am surely missing something here. Please help.
<br />
void main()<br />
{	<br />
	int *px;<br />
        const int p = 12;<br />
	px = (int *)&p;<br />
	*px = 20;<br />
	int y = p;<br />
	cout << y << " " << *px;	<br />
}


Then I tried this.
I made p a global variable. This one compiles without any error or warnings(highest level).
However throws access violation on *px = 20; at runtime! This is against my (wrong?) understanding of const.
Please can someone throw some light on this issue?

<br />
const int p = 12;<br />
void main()<br />
{	<br />
	int *px;        <br />
	px = (int *)&p;<br />
	*px = 20;<br />
	int y = p;<br />
	cout << y << " " << *px;	<br />
}<br />


I used MSVS 6.0 compiler.

modified on Friday, April 18, 2008 9:38 AM

GeneralRe: const issue... Pin
David Crow18-Apr-08 4:47
David Crow18-Apr-08 4:47 
GeneralRe: const issue... Pin
paulstandard18-Apr-08 5:01
paulstandard18-Apr-08 5:01 
GeneralRe: const issue... Pin
Matthew Faithfull18-Apr-08 6:49
Matthew Faithfull18-Apr-08 6:49 
GeneralRe: const issue... Pin
CPallini18-Apr-08 9:10
mveCPallini18-Apr-08 9:10 
Generalthat answers problem 2...thanks Mathew [modified] Pin
paulstandard18-Apr-08 9:56
paulstandard18-Apr-08 9:56 
Generalcause of problem one ... Pin
paulstandard18-Apr-08 10:35
paulstandard18-Apr-08 10:35 
QuestionHow to get rid of these errors [modified] Pin
pl_kode18-Apr-08 3:25
pl_kode18-Apr-08 3:25 
GeneralRe: How to get rid of these errors Pin
David Crow18-Apr-08 4:01
David Crow18-Apr-08 4:01 
QuestionRe: How to get rid of these errors Pin
CPallini18-Apr-08 4:02
mveCPallini18-Apr-08 4:02 
GeneralRe: How to get rid of these errors Pin
pl_kode18-Apr-08 4:24
pl_kode18-Apr-08 4:24 
QuestionRe: How to get rid of these errors Pin
David Crow18-Apr-08 4:43
David Crow18-Apr-08 4:43 
GeneralRe: How to get rid of these errors Pin
pl_kode18-Apr-08 5:00
pl_kode18-Apr-08 5:00 
QuestionRe: How to get rid of these errors Pin
David Crow18-Apr-08 5:07
David Crow18-Apr-08 5:07 
GeneralRe: How to get rid of these errors Pin
Iain Clarke, Warrior Programmer18-Apr-08 4:10
Iain Clarke, Warrior Programmer18-Apr-08 4:10 
QuestionMultiGraph Programming in VC++ Pin
Andy Rama18-Apr-08 2:40
Andy Rama18-Apr-08 2:40 
QuestionHow can I read the attributes of files? Pin
ritz123418-Apr-08 2:23
ritz123418-Apr-08 2:23 
AnswerRe: How can I read the attributes of files? Pin
Rajesh R Subramanian18-Apr-08 2:45
professionalRajesh R Subramanian18-Apr-08 2:45 

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.