|
#ifndef BYTE // For OS X -ers
#define unsigned char BYTE
#define unsigned char * LPBYTE
#endif
#include <vector>
#include <algorithm>
void separate(vector< pair<LPBYTE, LPBYTE> >& retVec, LPBYTE data, LPBYTE delimeter, bool *bComplete = 0) {
retVec.clear();
if (bComplete) *bComplete = false;
if (!data)
return;
LPBYTE dataEnd = data + sizeof(data);
LPBYTE delEnd = delimeter + sizeof(delimeter);
size_t delSize = distance(delimeter, delEnd);
LPBYTE found = std::search(data, dataEnd, delimeter, delEnd);
if (found == delEnd)
return;
cout << "In separate(...)\n";
if (data[0] == delimeter[0])
cout << "data[0] == delimeter[0]\n";
if (found == data)
cout << "Found == data.\n(" << found[0] << " == " << data[0] << ")\n";
if (found != data)
cout << "Found != data; found == data[" << distance(data, found) << "].\n";
return;
};
int main()
{
BYTE buffer[] = {',', '1', '2', '3', ',', '4', '5', '6', ',', '7', '8', '9', ',', 0};
BYTE del = ',';
bool bComp = true;
LPBYTE found = std::search(&buffer[0], &buffer[0] + sizeof(buffer), &del, &del + sizeof(del));
if (found == &buffer[0])
cout << "found == &buffer[0]\n";
else
cout << "found == &buffer[" << distance(&buffer[0], found) << "]\n";
vector< pair<LPBYTE, LPBYTE> > lpb;
separate(lpb, buffer, &del, &bComp);
return 0;
} Output:
found == &buffer[0]
In separate(...)
data[0] == delimeter[0]
Found != data; Found == data[4]
When I search from within main() , the leading comma is found, but once I pass the data & delimeter to separate() , it misses the leading comma and finds the next one.. obviously I'm missing something - can anyone spot what it is?
Your assistance is greatly appreciated!
MZR
|
|
|
|
|
In main(), del is of type BYTE and sizeof(del) is 1. Once it's passed to separate , del is of type LPBYTE and sizeof(del) is 4.
|
|
|
|
|
How do I put a CFormView in a CDockablePane? Basically, I'm trying to make the child window scrollable. Thanks.
|
|
|
|
|
I need a program in c to implement the problem of nearest neighbor method in C
|
|
|
|
|
singh.vikas8508 wrote: I need a program in c to implement the problem of nearest neighbor method in C
I need you to read the guidelines[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
At the bottom of this article [^] there are links to available libraries.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The "kind guy" makeover doesn't look good on you.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: The "kind guy" makeover doesn't look good on you.
I know.
BTW did you read this [^]? Now I must choose:
- Should I stop using sarcasm in my answers?
- Should I instead stop answering?
- Should I build the wall?
- Should I run for president?
- Should I trust the government?
- Will they put me in the firing line?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Should I stop using sarcasm in my answers?
The occasional sarcasm is good. Also, you're mature enough to keep it under acceptable levels, so I don't see a problem.
CPallini wrote: Should I instead stop answering?
WTF are you talking about.
CPallini wrote: Will they put me in the firing line?
I hope.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Well, I'm unhappy with Chris 'HOW TO ANSWER A QUESTION'. Anyway, of course, I'm not going to stop.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
My same exact thoughts. We always try our levels best to provide an answer that could be of help; but some questions CANNOT be answered and the OP WILL NOT learn, no matter what. Now, we can ignore such posts completely.
But like you said, I won't stop either.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
consider writing one yourself...
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
i need to measure a char width in a text , to detrmine where the user clicked.
void CTest_View::OnLButtonDown(UINT nFlags, CPoint point)
{
CString strInput;
strInput = "Text 1234";
int nX = point.x; // but this is the position in pixel.
}
please help.
Thanks
|
|
|
|
|
Let me google that for you![^] and remember that google or any search engine is your friend.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
What does it have to do with finding the character width? Can't you just call GetCursorPos()[^]?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
no because i need to find th x and y where the mouse clicked in order to mark the text to copy it.
|
|
|
|
|
susanne1 wrote: i need to find th x and y where the mouse clicked in order to mark the text to copy it.
Ugh... You need to find x and y? Ya know? That's *exactly* what GetCursorPos() does.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
CDC::GetTextExtent [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
This method gives me the width of the whole text, wht i exactly need, is the width in pixel for each charchter in the text.
|
|
|
|
|
Actually this method gives the width of the passed string, if you pass a single-character string then you get the width of such character.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
What are you trying to achieve exactly ? On what the user is supposed to click and what do you want to do in response ?
|
|
|
|
|
To get the character width you can use below sequence.
Firstly use GetCursorPos() to get the cursor point
and use HWND WindowFromPoint( POINT Point ) To get the handle and from that handle
use the below API in which the LPTEXTMETRIC haves the character width.
BOOL GetTextMetrics( HDC hdc, // handle to DC
LPTEXTMETRIC lptm // text metrics
);
i cannot understand whats your need to do such a step, well hope you are looking for the above
modified on Monday, July 13, 2009 4:46 AM
|
|
|
|
|
Hi Everyone,
Is it possible that when we burn any of the CD, it shouldn't get copied on any PC or it should not get Burned.if possible please send a sample.
Thanx in Advanced.
Shashi Bhushan
|
|
|
|
|
Read about it here - CD/DVD copy protection[^]
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Member 4603754 wrote: Urgent please
This clearly states you don't know forum guidelines, please read [^] carefully.
Member 4603754 wrote: Is it possible that when we burn any of the CD, it shouldn't get copied on any PC or it should not get Burned
?
Member 4603754 wrote: if possible please send a sample.
A sample CD?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|