|
This looked like a fun little project to create, so I took about 15 minutes of my time to write this. I'm not going to post the code (which was 29 lines from start to finish, including the #include statements.) I'm not sure if my approach is what you are looking for, but I set aside 5 variables (I made an array to hold these) of type unsigned short. Then I just wrote a for loop which looked at each character of the input string and added it to each variable (you have to reset one of the variables back to zero each pass through the loop, just use the mod operator.) At the end of my for loop I looked at my variable that I'm going to reset the next time through my loop (it should contain 5 characters by now) and if the bit pattern in this variable is the same as the bit pattern you are looking for, then it outputs the place in the string where this pattern came from. That's it!
Give this a try for a while and if it's killing you then post a reply to my message and I'll post you the code (I don't mind helping people with homework.) I wanted you to try it first since I gave you some ideas on how to approach this. Hopefully I wasn't too vague but I don't want to give away the entire solution right away!
Good luck!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
Hi! I have been assigned to design a database program that is capable of reading a barcode via a barcode device. The problem is, I have never done anything involving serial ports. Are there any good tutorials about serial ports or could you point me in the right direction by listing a few of the functions involved?
-- Steve
|
|
|
|
|
To open a COM port, you can use the CreatFile( ... )
To access COM port properties, use GetCommProperties(...)
To write to a COM port, use WriteFile(...)
see this link:
http://www.control.com/966781257/index_html
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
I have the following code:
<br />
void* fixaddr;<br />
DWORD delta<br />
.<br />
.<br />
.<br />
<br />
*((WORD *)fixaddr) += HIWORD(delta);<br />
.<br />
.<br />
.<br />
During compilation I get the following error:
warning C4244: '+=' : conversion from 'int' to 'unsigned short', possible loss of data
Since I don't want any warnings appear in my code I wonder how to fix this ?
|
|
|
|
|
You could turn down the warning level
|
|
|
|
|
cast HIWORD result to WORD:
*((WORD *)fixaddr) += (WORD)HIWORD(delta);
|
|
|
|
|
Which makes little sense since the HIWORD() macro already casts its result to a WORD . The int that the compiler is complaining about is on the left of the += operator, not the right.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I don't understand why, since the expression on the left IS a WORD. And we have no knowledge of this HIWORD macro; it maybe does not cast to a WORD.
|
|
|
|
|
I have reduced warning level to 3, and this warning does not appear.
Thanks for help!
|
|
|
|
|
Which does nothing but mask this and other potential problems. Leave the compiler warning level at 4 and fix the problem correctly. The compiler generates warnings/errors for a reason. If something wasn't suspect, there'd be no reason to warn you.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
How refreshing! It's not just me that works that way, then
(The more of your replies I read, the more I wish you worked at the same place I do...) [fx: toadying mode off]
Steve S
|
|
|
|
|
Hi, newbie here,
I was wondering what's the best way to use the CMemoryState object to check for memory leaks in a MFC program.
I want to set a checkpoint at the very beginning of the program and the very end, so in what functions should I call
oldState.Checkpoint() and newState.Checkpoint()?
|
|
|
|
|
Call the CheckPoint() method of a CMemoryState object where you want to start tracking. At the point where you want to stop tracking, call the CheckPoint() method of a second CMemoryState object. Then, call the Difference() method of a third CMemoryState object, passing to it the other two CMemoryState objects.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I know how to use the functions, I want to know where is the best place to call them in the App.
I was calling the oldState.Checkpoint() in the App() and
newState.Checkpoint() in App::ExitInstance() but it returned a difference.
When I called oldState.Checkpoint() it listed (I think) a CDocTemplateManager object and a CSingleDoctemplate object.......
So this is obviously not the best place to call oldState.DumpAllObjectsSince() to check overall memory usage.
Is there a function after App::ExitInstance to do the difference check in?
|
|
|
|
|
Generally speaking, in a DEBUG build you'll get this behaviour anyway providing your CPP files have the '#define new ....' stuff in them.
Are you calling CheckPoint before or after calling the base ExitInstance()?
Steve S
|
|
|
|
|
I don't know what you mean by '#define new..."
I'm overriding the MFCApp::ExitInstance() function and calling the base ExitInstance(). Then I do the object dump, so I can't see why a few objects are still allocated.
BTW I am extremely paranoid about memory leaks after having lots of trouble with my last PC (crashing.......sloooowdown etc..)
|
|
|
|
|
I need to link to this lib ws2_32.lib, and would like to know how to do this in the project->settings->link tab.
What exactly do I type in, and where in the project->options text box in the link tab?
Thanks,
ns
|
|
|
|
|
ns wrote:
I need to link to this lib ws2_32.lib, and would like to know how to do this in the project->settings->link tab.
Enter ws2_32.lib in the Object/library modules box.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Appreciate the speedy response
Thanks,
ns
|
|
|
|
|
#pragma comment(lib, "ws2_32.lib") also does the trick
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi
I am creating a project (base in a single document), I modified the initial class *View(at the end of the wizard) to be based in CFormView, so that the project is like one based on dialogs (but with other classes and format).
I set up a tabcontrol in the window, and I want to get the other frames because nothing appears in the tab.
I made some other examples but as this one is based on other classes, I have no idea how to get the information.
Can anybody help?
Thanks
rubencmos@hotmail.com
rubencmos@hotmail.com
|
|
|
|
|
This should get you started:
http://msdn.microsoft.com/msdnmag/issues/0600/wicked/default.aspx
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I really apreciate that.
Thanks so much that was really what I was looking for.
Thanks again. Ruben
|
|
|
|
|
I see that given an ftp site, you can use CInternetSession, CFTPConnection with
char* ftpserver = "ftp.microsoft.com" for e.g.
So if I have instead an IP adress for a computer, how do I get the CString for the fptserver.
Basically I need to download some data files off a given IP adress programmatically. Any suggestions appreciated.
Thanks,
ns
|
|
|
|
|
See this project in sourceforge.net
http://sourceforge.net/projects/filezilla/
You can download the source from this URL.
|
|
|
|