|
I donot know your C program.
Please talk me you realize the function.
I come from China.My English is not good.I hope you can understand my replay.
|
|
|
|
|
Dear all:
I get touch data by used HID.dll, it is raw data.
I wanna process the raw data, before send it to OS.
How can I send touch to OS, using postmessage or sendmessage?
if so, How can I use it?
Thank for your help, Victor.
|
|
|
|
|
Hello All, Could you help me speed up a program? It's designed to find the square root of a number.
<pre lang="c++">
#include<iostream>
using namespace std;
int main()
{
float a;
float c;
cout << "Square root calculator!" << endl;
cout << "Enter the number you want to square root" << endl;
cin >> a;
cout << "Enter an educated guess" << endl;
cin >> c;
cout << "The squareroot of " << a << " is: " << endl;
do
c = (c + (a/c))/2;
while ( c != a/c );
{ cout << c << endl;
}
return 0;
}
</pre>
My problem is that it get remarkably slow around 55ish. Any advice it appreciated
|
|
|
|
|
|
I'm guessing your issue is the while(). Comparing two floats can be tricky.
while ( c != a/c );
this[^] link may help.
|
|
|
|
|
That is the problem with the Babylonian method you have used.
Paul Hsieh has a very good webpage on everything about square roots but were afraid to ask.
http://www.azillionmonkeys.com/qed/sqroot.html[^]
It includes details most of the techniques from the standard C library, to the faster integers version that NVidia and Quake use.
|
|
|
|
|
hi..i have a requirement to write C/c++ application that converts Microsoft Word
(.doc) Documents into XML format. The application should be able to receive/open a Word document and save a XMl file with the same
name, but with the extension .xml..ur valuable suggestions will help me n will be appreciated..thanks
|
|
|
|
|
|
is there any library file to include in the code?..how to convert the entire docx formate?
|
|
|
|
|
You need to follow some of those links and do some research. As I said, reading Word documents in C/C++ is not particularly easy, unless you are familiar with C++/CLI, in which case you can use the Microsoft.Office.Interop.Word Namespace[^]
|
|
|
|
|
yes i have good experience in c++ but i have not worked on this requirements..if so i can read the data but question is how to store tht in xml format...suggestions will be greatly appreciated
|
|
|
|
|
krishnaprasad t wrote: how to store tht in xml format Store what? A word document is just like a book, lots of words separated by punctuation characters. In order to store that as XML you will need to design a set of rules and tags to split the data into logical sets. Each set would probably need some attrinutes, such as font (character set, height, fixed or true-type, bold, italic etc.). Writing the final XML is just a question of using one of the XML libraries available, either Microsoft or third-party.
|
|
|
|
|
thank u for ur reply..can u pls provide me links it would great help
|
|
|
|
|
I already gave you a link to the Word Interop. You should be able to search MSDN for yourself to find other pages of interest.
|
|
|
|
|
I'm thinking the easiest way would be to use Office Automation.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
why do we use %u while outputting addresses????
|
|
|
|
|
I would say that %p is preferred. Maybe this[^] link will help.
|
|
|
|
|
%u is not a good choice for outputting memory addresses.
Personally, I use %p or %x for memory addresses.
Look here for printf type fields - printf Type Field Characters[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
As shown below, there are a few functions in CButton, but i want to change its behaviour by dealing with
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) . Yes, just this one and only one functon. It would generate more code than expected if I derive a class from CButton. I wonder if it possible to process this function without Subclass, and not use derivation. If so, how?
Remarks: I must use MFC, it's so hard to use pure Win32 API.
class CButton : public CWnd
{
DECLARE_DYNAMIC(CButton)
public:
CButton();
virtual BOOL Create(LPCTSTR lpszCaption, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID);
UINT GetState() const;
void SetState(BOOL bHighlight);
int GetCheck() const;
void SetCheck(int nCheck);
UINT GetButtonStyle() const;
void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE);
HICON SetIcon(HICON hIcon);
HICON GetIcon() const;
HBITMAP SetBitmap(HBITMAP hBitmap);
HBITMAP GetBitmap() const;
HCURSOR SetCursor(HCURSOR hCursor);
HCURSOR GetCursor();
#if (_WIN32_WINNT >= 0x501)
AFX_ANSI_DEPRECATED BOOL GetIdealSize(_Out_ LPSIZE psize) const;
AFX_ANSI_DEPRECATED BOOL SetImageList(_In_ PBUTTON_IMAGELIST pbuttonImagelist);
AFX_ANSI_DEPRECATED BOOL GetImageList(_In_ PBUTTON_IMAGELIST pbuttonImagelist) const;
AFX_ANSI_DEPRECATED BOOL SetTextMargin(_In_ LPRECT pmargin);
AFX_ANSI_DEPRECATED BOOL GetTextMargin(_Out_ LPRECT pmargin) const;
#endif // (_WIN32_WINNT >= 0x501)
#if ( _WIN32_WINNT >= 0x0600 ) && defined(UNICODE)
CString GetNote() const;
_Check_return_ BOOL GetNote(_Out_z_cap_(*pcchNote) LPTSTR lpszNote, _Inout_ UINT* pcchNote) const;
BOOL SetNote(_In_z_ LPCTSTR lpszNote);
UINT GetNoteLength() const;
BOOL GetSplitInfo(_Out_ PBUTTON_SPLITINFO pInfo) const;
BOOL SetSplitInfo(_In_ PBUTTON_SPLITINFO pInfo);
UINT GetSplitStyle() const;
BOOL SetSplitStyle(_In_ UINT nStyle);
BOOL GetSplitSize(_Out_ LPSIZE pSize) const;
BOOL SetSplitSize(_In_ LPSIZE pSize);
CImageList* GetSplitImageList() const;
BOOL SetSplitImageList(_In_ CImageList* pSplitImageList);
TCHAR GetSplitGlyph() const;
BOOL SetSplitGlyph(_In_ TCHAR chGlyph);
BOOL SetDropDownState(_In_ BOOL fDropDown);
HICON SetShield(_In_ BOOL fElevationRequired);
#endif // ( _WIN32_WINNT >= 0x600 ) && defined(UNICODE)
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
public:
virtual ~CButton();
protected:
virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
};
|
|
|
|
|
|
|
Falconapollo wrote: how about Hook? What does that have to do with drawing a CButton ? Hooks are system wide so you would need to capture every drawing message and then decide whether it was for your control or not. That's like using a big hammer to crack a small nut.
|
|
|
|
|
Inheritance is the natural way for doing that. Any other way (if feasible) would be contrived.
Veni, vidi, vici.
|
|
|
|
|
|
Hi.
A friend of mine wrote this crazy function in VB and i have translated it to C++ in hopes that we could get a bit better performance. I guess the performance might be a bit better but it is still an enourmous amount of loops to go through.
Do you have any suggestions on how to optimize this loop or perhaps replace it completely to be able to finish all iterations in a managable time? Is it hard to have it run on the GPU and would that improve anything?
//
Parre
int CountTheOffsetValids() {
int c0;
int c1;
int c2;
int c3;
int c4;
int c5;
int c6;
int c7;
int c8;
int c9;
int c10;
int c11;
int c12;
int c13;
int c14;
int c15;
int c16;
int c17;
int c18;
int c19;
int llim [20] = {1, 2, 5, 8, 11, 14, 17, 21, 24, 28, 31, 35, 38, 42, 45, 50, 53, 58, 61, 66};
int hlim [20] = {6, 10, 14, 19, 22, 26, 29, 34, 37, 41, 44, 48, 51, 54, 57, 61, 63, 67, 69, 70};
for (c0 = llim[0]; c0 <= hlim[0]; ++c0) {
arrVals[0] = c0;
for (c1 = llim[0]; c1 <= hlim[1]; ++c1) {
arrVals[1] = c1;
if (c1 > c0) {
for (c2 = llim[2]; c2 <= hlim[2]; ++c2) {
arrVals[2] = c2;
if (c2 > c1) {
for (c3 = llim[3]; c3 <= hlim[3]; ++c3) {
arrVals[3] = c3;
if (c3 > c2) {
for (c4 = llim[4]; c4 <= hlim[4]; ++c4) {
arrVals[4] = c4;
if (c4 > c3) {
for (c5 = llim[5]; c5 <= hlim[5]; ++c5) {
arrVals[5] = c5;
if (c5 > c4) {
for (c6 = llim[6]; c6 <= hlim[6]; ++c6) {
arrVals[6] = c6;
if (c6 > c5) {
for (c7 = llim[7]; c7 <= hlim[7]; c7) {
arrVals[7] = c7;
if (c7 > c6) {
for (c8 = llim[8]; c8 <= hlim[8]; ++c8) {
arrVals[8] = c8;
if (c8 > c7) {
for (c9 = llim[9]; c9 <= hlim[9]; ++c9) {
arrVals[9] = c9;
if (c9 > c8) {
for (c10 = llim[10]; c10 <= hlim[10]; ++c10) {
arrVals[10] = c10;
if (c10 > c9) {
for (c11 = llim[10]; c11 <= hlim[11]; ++c11) {
arrVals[11] = c11;
if (c11 > c10) {
for (c12 = llim[12]; c12 <= hlim[12]; ++c12) {
arrVals[12] = c12;
if (c12 > c11) {
for (c13 = llim[13]; c13 <= hlim[13]; ++c13) {
arrVals[13] = c13;
if (c13 > c12) {
for (c14 = llim[14]; c14 <= hlim[14]; ++c14) {
arrVals[14] = c14;
if (c14 > c13) {
for (c15 = llim[15]; c15 <= hlim[15]; ++c15) {
arrVals[15] = c15;
if (c15 > c14) {
for (c16 = llim[16]; c16 <= hlim[16]; ++c16) {
arrVals[16] = c16;
if (c16 > c15) {
for (c17 = llim[17]; c17 <= hlim[17]; ++c17) {
arrVals[17] = c17;
if (c17 > c16) {
for (c18 = llim[18]; c18 <= hlim[18]; ++c18) {
arrVals[18] = c18;
if (c18 > c17) {
for (c19 = llim[19]; c19 <= hlim[19]; ++c19) {
arrVals[19] = c19;
if (c19 > c18) {
std::cout << loopCounter << "lines processed." << std::endl;
loopCounter++;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return isv;
}
modified 2-Mar-14 20:57pm.
|
|
|
|