|
i don't know what you're trying to do, but if you're assigning 123456789abc into your char[3] variable, firstly, there's not enough characters to store it, and secondly, a C-style string must be null terminated.
now, please specify what format is supposed to be the char[3] because we are blind and so cannot help you much.
if you want some help, you have to give us the minimum informations for us to understand exactly what you're doing wrong.
so start it again, ,and please answer these questions :
1. how is defined m_1E2
2. how is defined temp
3. how is initialized baSlots ?
4. what is m_1E2.GetLine() supposed to do ?
5. is your 123456789abc value an integer or a string.
6. not a question but an important point : if your writing the 123456789abc integer into the temp string, temp must be at least 13 characters wide, so that the 13st character can be '\0' (null termination)...
hope you understand now.
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
Toxcct,
please see the code below :
unsigned char baSlots[6];
MessageBox(m_1E2val); //m_1E2val is member variable of edit
//box with type string
sscanf(m_1E2val,"%x",&baSlots);
now, when I check in debug,
after entering "123456789abc" in the editbox and on reaching the function with the above code,
with MessageBox(m_1E2val), I get correct string whatever I have entered.
but after
sscanf(m_1E2val,"%x",&baSlots)
in the debug window I see baSlots as
[0x0] 0xbc '¼'
[0x1] 0x9a 'š'
[0x2] 0x78 'x'
[0x3] 0x56 'V'
[0x4] 0xcc 'Ì'
[0x5] 0xcc 'Ì'
I am wondering where the 1234 went?
- KK
|
|
|
|
|
change the sscanf(m_1E2val,"%x",&baSlots); into this :
for (int i = 0; i < 6; i++) {
::sscanf(m_iE2val.Mid(i*2, 2), "%x", &baSlots[i]);
}
actually, i read here the hexa characters 2 by 2...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
-- modified at 9:19 Friday 10th February, 2006
|
|
|
|
|
err.
I get Unhandled exception 0xc00000005 Access violation
- KK
|
|
|
|
|
I got it working. added '&' before baSlots.
sscanf(m_1E2val.Mid(i*2, 2), "%x", &baSlots[i]);
now I get it correctly. still do not understand what is wrong with
sscanf(m_1E2val, "%x", &baBeaconSlots);
- KK
|
|
|
|
|
kk_vp wrote: added '&' before baSlots
yeah, fixed my mistake...
kk_vp wrote: still do not understand what is wrong with sscanf(m_1E2val, "%x", &baBeaconSlots);
in fact, "%x" reads 2 hexadecimal characters and writes a single byte... so, you'd have to write
::sscantf(m_1E2val, "%x%x%x%x%x%x", baSlots[0], baSlots[1], baSlots[2], baSlots[3], baSlots[4], baSlots[5]);
which is worse - IMO - as the little for() loop i provided you...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
-- modified at 9:46 Friday 10th February, 2006
|
|
|
|
|
kk_vp wrote: MessageBox(m_1E2val); //m_1E2val is member variable of edit
If m_1E2val is indeed a CEdit object, then this statement is in error. Are you sure it's not a CString object instead?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
It is a CString type member variable of CEdit
I got it working. added '&' before baSlots.
sscanf(m_1E2val.Mid(i*2, 2), "%x", &baSlots[i]);
now I get it correctly. still do not understand what is wrong with
sscanf(m_1E2val, "%x", &baBeaconSlots);
- KK
|
|
|
|
|
kk_vp wrote: It is a CString type member variable of CEdit
There's no such thing. It's either one or the other.
kk_vp wrote: still do not understand what is wrong with
sscanf(m_1E2val, "%x", &baBeaconSlots);
Since you are the only one that knows what baBeaconSlots is, we can only guess as to what the problem might be.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
DavidCrow wrote: There's no such thing. It's either one or the other.
he certainly don't know exactly what he's doing (MFC is sometimes dark for newbies).
he might want to say a CString on a CEdit member variable...
DavidCrow wrote: Since you are the only one that knows what baBeaconSlots is, we can only guess as to what the problem might be.
hmm, seems that baSlots turned into baBeaconSlots , but anyway, it remains char[6] .
but i fixed his problem now...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
baBeaconSlots is also
unsigned char[6], just like baSlots
- KK
|
|
|
|
|
How to add one more window in MDI application project.I Created the project.But now i want to include it.
How can i do this?
|
|
|
|
|
First create a view class by class wizard.
Add a CDocTemplate class member(pointer) to your App class.
lets say m_newView.
Now at InitInstance()
m_newView = new CMultiDocTemplate(
ID,
RUNTIME_CLASS(Document class),
RUNTIME_CLASS(Frame Class),
RUNTIME_CLASS(View class));
AddDocTemplate(m_newView);
for more detail just search in this site you will get lot many examples.
Regards
Anil
|
|
|
|
|
HI!!!
Could anybody tell me the usage XmlCDataSection.
Is this can be used in mfc application, in windows xp environment. Wat for is this used?? How to use it?? or can anybody provide me with an example of it, for reference.
Thanx
"If you change then change for the good."
|
|
|
|
|
This is one exmaple why the CDATA element type is used...
We use CDATA sections in our XML files so our product's scripting language can be embedded within the XML without freaking the XML parsers.
For example, we might have a script line like this:
iTag001 <> 10;
If you don't put that in CDATA and and XML parseer tries to interpret it, you will have trouble.
So, now we have a node like this:
<ONHIDE>
<SCRIPT>
<![CDATA[
IF iTag001 <> 10 THEN
iTag001 = 10;
ENDIF;
]]>
</SCRIPT>
</ONHIDE>
Instead of like this:
<ONHIDE
SCRIPT = '
IF iTag001 <> 10 THEN
iTag001 = 10;
ENDIF;
'>
</ONHIDE>
We use the straight XML COM calls and interface pointers to process the XML, so I can't help you directly with the XmlCDataSection.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
I created a SDI app. project.Now i want to add one more window to display the graph..in my project.
How can i do this???
|
|
|
|
|
Hi..I created a project in SDI..But i have to plot a graph,so i need a new window in my project.
How can i add a new view window to my project?
Can anybody help me???
|
|
|
|
|
|
How do i make use of automation to extract the text of a word document already open by automation?
|
|
|
|
|
I have one more problem actually my class view of project work space is not showing all the classes in my folder. In my project there are around more than 200 classes. In the old directory i where my code is there i can see all the classes but when i move the code to any other directory or rename the original directory i am able to see only one class. Can any one please help me in this regard.
|
|
|
|
|
[Close project(solution)] --> [delete *.ncb file] --> [re-open project].
Maxwell Chen
|
|
|
|
|
Max/Anil,
Gr8 dudes. I deleted the .ncb file and reopened. It's really working. Can you people please send me your personal ids i have a real problem that needs a bit more explanation. Please do me a favou by sending your ids i need your help badly. Again thanks a lot for your valuable suggestions.
|
|
|
|
|
why don't you post your message here only.
That way you will get more response and more explanations.
any way you can mail any member by the mail option below.
Regards
Anil
|
|
|
|
|
Hey Anil,
I have sent a mail to your gmail account. Please have a look when you are free.
|
|
|
|
|
BiswaR wrote: I have sent a mail to your gmail account
please, stop this ASAP. if you come on a forum to ask for help, we assume that it is for sharing (which is the fundamentals of a technical forum). if you don't want this, don't ask your problem there, and find someone in your nears who can help you
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|