473,765 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System error on pointer program

I'm getting a system error on this piece of code on WinXP:

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
volatile int* p=reinterpret_c ast<int*>(0x598 61);
for(int i=0;i<20;i++)
cout << *p << endl;
system("PAUSE") ;
return EXIT_SUCCESS;
}

Why does it keep crashing? And what's the mem address of the system
clock for WinXP? Thanks!!!!

Feb 28 '06 #1
2 1599
Protoman wrote:
I'm getting a system error on this piece of code on WinXP:

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
volatile int* p=reinterpret_c ast<int*>(0x598 61);
Where is any guarantee that '0x59861' is a pointer to an int?
for(int i=0;i<20;i++)
cout << *p << endl;
You're dereferencing a pointer here which is most likely invalid,
which constitutes _undefined_beha viour_.
system("PAUSE") ;
return EXIT_SUCCESS;
}

Why does it keep crashing?
Your program has undefined behaviour. It can do whatever it pleases.
And what's the mem address of the system
clock for WinXP? Thanks!!!!


Shouldn't you ask this in a WinXP newsgroup?

V
--
Please remove capital As from my address when replying by mail
Feb 28 '06 #2
Protoman wrote:
I'm getting a system error on this piece of code on WinXP:

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
volatile int* p=reinterpret_c ast<int*>(0x598 61);
for(int i=0;i<20;i++)
cout << *p << endl;
system("PAUSE") ;
return EXIT_SUCCESS;
}

Why does it keep crashing?
It probably has something to do with you trying to access a specific
address. Probably this address isn't a valid one, so your OS decides to
terminate your program.
And what's the mem address of the system clock for WinXP? Thanks!!!!


No idea. But under modern operating systems, you usually don't get direct
access to specific memory locations. On such OSs, the addresses you are
using are typically not even real memory addresses, but rather part of a
virtual address space created for your program. You're supposed to access
specific hardware through driver interfaces of your system. This is to
prevent programs from bringing the whole system down by messing up the
hardware.
How to do that, you best ask in a newsgroup about WinXP programming.

Feb 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
6692
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that assert could be used to start an interactive debugger automatically. How do I realize that on a Linux machine using gcc?
14
2814
by: prasadjoshi124 | last post by:
Hi All, I am writing a small tool which is supposed to fill the filesystem to a specified percent. For, that I need to read how much the file system is full in percent, like the output given by df -k lopgod10:~/mycrfile # df -k /mnt/mvdg1/vset Filesystem 1K-blocks Used Available Use% Mounted on
1
23424
by: urkel | last post by:
Hi everyone, I critically need help to solve this problem related to pointer in C++ Basically, I have a C/C++ program "retardselfenerg" calling a Fortran 90 subroutine "surfGF4.f90". i am so doubtful if my definitions of pointer variables and their use in calling function are correct. #include<bla bla bla......h> #include<bla bla bla.h> double surfGF4_(double*, double*, double*, double*, double*, double*, double*, double*, double*); ...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.