|
dlarkin77 wrote:
What I would like to do is to create the arrays as soon as my application starts so that they are readily available when they are needed by the other dialogs.
What is the best way to do this?
You can either make the arrays members of the CWinApp class, or make them static members of a CDialog -based class of which your other two dialogs are derived from.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I was given a data file to read which is in binary format. I was told that the data starts in the file at position 0x1000. Each value following the offset is a 2byte short value. I tried reading in the file using fstream.ReadInt16(). It looks like some of the data is matching up correctly but the other isn't. Below on the left is what the data should be and on the right is what i'm getting
2 2
68 -188
-22 234
18 18
85 85
130 386
454 710
626 114
82 82
127 639
617 617
558 -210
As you can see some of it is matching up. Does anyone know what i'm doing wrong??
|
|
|
|
|
What is the content of the binary file for these numbers. Since the translation is out by either 0, 256, 512 or 768 in all cases it would suggest the binary format is not what you expect it.
Windows expects LSB then MSB. It suggests that the binary file is MSB then LSB.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
The data is suppose to be x and y coordinates, so +/- integer values. I wasn't given any more information besides that. Is this a text encoding problem? Do you have any suggestions on how to test the LSB and MSB problem, I'm not very familiar with this or with binary file reading in general.
thanks for the response
|
|
|
|
|
You may want to read up on Big Endian and Little Endian byte order for number representation.
Intel Processors are Little Endian (PCs) Motorola Processors are Big Endian. Depending on how the file was created and on what operating system it could be stored either way.
Little Endian is LSB then MSB. Big Endian is MSB then LSB.
e.g. The hex value 0x7FFF when stored in:
Little Endian = FF 7F
Big Endian = 7F FF
within the file.
Note: Network packets have numbers stored in Big Endian no matter what OS originated them.
I would suggest reading the raw data into a buffer then looking at the buffer contents (2-bytes at a time). You may be able to analyse why the numbers are not showing as you expect.
Note: For a signed short(2-byte integer) the positive values will be 0x0000..0x7FFF and the negative values are 0x8000..0xFFFF.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
It looks, like after you read two bytes into buffer, you put a garbage in high byte, low byte is always correct:
68=0x0044, -188=0xff44
-22=0xffea, 234=0x00ea
130=0x0082, 386=0x0182
... etc
You have a bug somether in your program. Either two varables share the same memory, or you read just one byte and forget another, or....
|
|
|
|
|
hi people i am a college student at the moment currently trying to figure out c and it aint happenin. I need help with 2 things: -
1.i need code for a decimal to hexadecimal converter without using things such as printf etc in the function
2. i need code for a program to convert strings of text all to uppercase again without using printf etc in the function.
any help will be greatly appreciated and will help me not fail me course.
|
|
|
|
|
I have good news and bad news. The good news is - there is google and many, many tutorials out there. The bad news - if this is giving you trouble, it's going to get worse. You need to plug away and do your homework....
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
Bobsyourmother wrote:
1.i need code for a decimal to hexadecimal converter without using things such as printf etc in the function
Even if you were allowed to use printf() , it would not help in the conversion of base-10 to base-16. While it's true that printf("%#x", 45) would display 0x2d, the number was not actually converted, it was just displayed in a different base.
Counting in different bases is really easy once you know what's going on. The reason that we count in base-10 is because of the number of digits we have on our hands. Were we born with eight digits, our numbering system would be in base-8 instead. That said, the number 2468 in base 10 is:
2x103 + 4x102 + 6x101 + 8x100
In base-8, it would be 4644 or:
4x83 + 6x82 + 4x81 + 4x80
People often think that a computer is this mystical device that somehow manages to do something that people cannot. Wishful thinking but it does the same thing that a person can do only faster and more efficient (e.g., a faster computer doesn't fix bugs, it only makes them faster!). If you cannot do it with pencil and paper, the computer can't do it either! That said, you need to figure out how to do the conversion on paper and then converting that to code will be much easier.
Bobsyourmother wrote:
2. i need code for a program to convert strings of text all to uppercase again without using printf etc in the function.
The ASCII value of 'a' is 97. The ASCII value of 'A' is 65. That should say to you that each lowercase character would need 32 subtracted from it for the uppercase equivalent.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I wish there was a filter to prevent redundant and do my homework for me questions...
These I find are more annoying that advertisements in article forums...
Ahhhh man....
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
I agree but it's a fine line. I've asked a few questions recently which clearly weren't 'real life' scenarios but interview questions I've had and answered. I wanted to know what others think. It's interesting that you get three or for people answering and get three of four different answers. It really is a superb way to learn. I think if you're up front about why you'er asking, then the reader can make the choice whether to answer or not.
Also, to ease my guilt, I do also cut'n'paste the code I've actually tried to get working and not just ask - 'How do I do this?'.
You got to credit this guy with the sheer brassnecked approach. Just hope he has access to CP in his exam (like I wished I had it in my last interview!).
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
In C language:
1. Use sprintf or scanf to store result in string
2. In ASCII table:
small letter: from a=97 dec (0x61) to z=122 dec (0x7a)
big letter: from A=65 dec (0x41) to Z=90 dec (0x5a)
97(a)-32(0x32)=65(A) ... 122(z)-32=90(Z)
|
|
|
|
|
thanx m8 for the help i appreciate all that helped and people who say jus keep tryin dont u think i have this was me last resort come on ive been using c for a month at most and i cant grasp it not me fault and by the way its all assignmemts so no exams thx again helpers i am intedebted
|
|
|
|
|
Greetings,
Frustrations from yesterday.I am trying to load a bitmap into a CBitmap object. I have succesfully done this 100 times before but this time I get an assertion error caused at AfxMakeResourceHandle(). I am calling the LoadBitmap() function at the constructor so it only takes place ones, so its not a problem of loading a bitmap over an existing one.
The image exists and the path is correct and the function is as follows:
[code]
m_bmKnob.LoadBitmap(IDB_51MAX);
[/code]
I have already made sure that there is no duplicate IDB number. Cannot find any informationm about this elsewhere. Something tells me its something very small and silly that I am missing but I have been going over and over it with no luck...
Thanks!
|
|
|
|
|
Some more details...
According to MSDN AfxGetResourceHandle is:
Use the HINSTANCE handle returned by this function to access the
application's resources directly, for example, in calls to the Windows
function FindResource.
Example
//Load the menu specifying the module handle where resource is to be
//found & resource ID
HMENU hMenu = ::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_PANEL));
I have also tried:
m_bmKnob.FromHandle(LoadBitmap(_AtlBaseModule.GetModuleInstance(),
MAKEINTRESOURCE(IDB_51MAX)));
That compiles and doesn't give an assertion, however later when the bitmap
needs to be used it crashes as actually nothing was ever "sucessfully" loaded
into theCBitmap file.
Does this shed any light into possibilities? I willl post any progress as soon as there is some...have a nice weekend!
|
|
|
|
|
|
Hello,
The project contains several ATL based ActiveX controls with MFC support, the resources are added to the project.
|
|
|
|
|
Well...
it seems the answer is the following:
[code]
CBitmap myBitmap;
AFX_MANAGE_STATE(AfxGetStaticModuleState());
myBitmap.LoadBitmap(IDB_SOMEBITMAP);
[/code]
Now I need to figure out what that all means!
Ciao
|
|
|
|
|
Hi!
I've created an XML file in VS.NET.
I've created a Schema with "Create Shema" on the XML-menu.
My XML-file then look like this:
?xml version="1.0" encoding="utf-8"?<br />
ROOT xmlns="http://tempuri.org/XMLFile1.xsd"<br />
ELEM<br />
/ELEM<br />
/ROOT
(Taken away the > and < signs)
The Schema-file (XMLFile1.xsd) now exists in the current dir.
How do I now validate my XML against that Schema?
When I press: "Validate XML Data" on the on the XML-menu I got the following error:
Visual Studio could not locate a schema for this document. Validation can only ensure this is a well formed XML document and cannot validate the data against a schema.
_____________________________
...and justice for all
APe
|
|
|
|
|
I have a string that's about 450 bytes that I want to assign to a CString, but the string is getting cut off.
CString rawData(i_pszRawData);
int buffLen = rawData.GetLength ();
buffLen is always 230 and not 450 bytes!
If these an embedded zero or null character or binary zero in the string, is there a way around it so that the full 450 is assigned to the CString?
Thanks.
-C
|
|
|
|
|
Wheatbread wrote:
If these an embedded zero or null character or binary zero in the string, is there a way around it so that the full 450 is assigned to the CString?
CStrings are designed to hold zero-terminated strings. if you need to hold arrays with zeros in them, you'll need to use something else, like an array of BYTEs.
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
Hi, I have encountered a problem with a very basic operation. does anybody have any idea about this?
Please see sample code below:
//////////////////////////////////////////
double a, b;
a = 99.99
b = 99.99
if (a <= b){
::MessageBox(NULL, L"TRUE", L"", MB_OK);
}
else{
::MessageBox(NULL, L"FALSE", L"", MB_OK);
}
//////////////////////////////////////////
somehow, it always display FALSE. Anybody knows how to handle this situation?
SDE
|
|
|
|
|
Doubles are NOT precise numbers. They are approximate representations. Whenever you need to compare doubles (or check if zero), you need to do approximate math, using an acceptable number of precision digits to your app. An example is below:
BOOL IsDoubleZero(double dVal)
{
if (dVal < 0.000001 && dVal > -0.000001)
return TRUE;
return FALSE;
}
BOOL AreDoublesEqual(double dVal1, double dVal2)
{
doubld dDiff = dVal1 - dVal2;
if (dDiff < 0.000001 && dDiff > -0.000001)
return TRUE;
return FALSE;
}
onwards and upwards...
|
|
|
|
|
Wow - never knew that. What about floats? Same thing? Hope so else I just screwed up an interview question!
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Angel1058 wrote:
What about floats? Same thing?
Yes.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|