|
Thanks for that, but I forgot to mantion that I want to write in C++ rather than C. So I would need some c++ API.
Heh, I've just realised that ASIO is an API. So, thank you one more time for help.
|
|
|
|
|
Hi,
I have a process that need to check a string formating. How the best way to check it ?
My client receive a e-mail with a field to fill a date "DD/MM/AAAA". when i receive the answer i need to check if the "/" and values for DD, MM and AAAA
or
My client receive a e-mail with a field to fill a value "9999" with range 10 to 1500.
I whould like a way to check it directy for true or false.
Someone can help me ?
|
|
|
|
|
for the date thing, i would just do it with simple CString search functions.
off the top of my head....
if (inString.GetLength()==10)
{
if (inString.GetAt(2) == '/' && inString.GetAt(5) == '/')
{
csDD = inString.Mid(0, 2);
csMM = inString.Mid(3, 2);
csYYY = inString.Mid(6, 4);
}
}
that's really brittle and won't accept things like "9/28/1927" or "5/5/05". but if you want to strictly enforce two-digit D and M and four digit Y, then that's all you need.
|
|
|
|
|
Use CStringT::Tokenize[^].
In this case the function must return 3 values in a loop.
The first value will be DD and the next MM and the next AAAA.
You could do the validation on these values.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
SNArruda wrote: My client receive a e-mail with a field to fill a date "DD/MM/AAAA". when i receive the answer i need to check if the "/" and values for DD, MM and AAAA
For dates, how about something like:
COleDateTime date;
date.ParseDateTime("17/9/2009");
if (date.GetStatus() != COleDateTime::valid)
...
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Can anyone suggest a good study book for C/C++/VC++2008.
The book should be intermidiate/advanced.
My background is that i have read Programming in C by Byron S. Gottfried.
|
|
|
|
|
Here[^] is my list of recommended books.
|
|
|
|
|
Ivor Horton has a good book on Visual C++ 2008.
He teaches C++ in the first half of the book and Windows Programming in the second half. He's still uses MFC for most of the book (which is a good thing IMO) but he has adapted and incorporated WinForms and some managed code for those who want it.
I've been very impressed with his teaching style and his choice of topics to cover.
|
|
|
|
|
#include<stdio.h>
#define abs(x) ((x<0)?(-(x)):(x))
#define epsilon .000000000001
#define size 5
double multiply(a,m,product)
double a[size][size],product [size][size];
int *m;
{
int test=0;
int count,i,j,k,l;
double olda[size][size],diff;
for(i=0;i<*m;i++)
for(j=0;j(* m;j++)
olda[i][j]=a[i][j];
for(count=1;count<=1000;count++)
{
for(i=0;i<*m;i++)
for(j=0;j<*m;j++)
product[i][j]=0;
for(i=0;i<*m;i++)
for(j=0;j<*m;j++)
for(k=0;k<*m;k++)
product[i][j]=product[i][j]+a[i][k]*olda[k][j];
for(i=0;i<*m;i++)
for(j=0;j<*m;j++)
{
diff=abs(product[i][j]-olda[i][j]);
if(diff>epsilon)
{
test=1;
for(k=0;k<*m;k++)
for(l=0;l<*m;l++)
olda[k][l]=product[k][l];
}
break;
if(test<1)
{
printf("\nThe numberof iterations is:");
printf("\n");
printf("\n %d",count);
break;
}
test=0;
}
return(0);
}
main()
{
static double a[size][size]={{0.1,1.0,0.0,0.0,0.0},
{0.0,0.0,0.3,0.7,0.0},
{0.0,0.0,0.0,0.2,0.8},
{0.0,0.0,0.1,0.0,0.9},
{1.0,0.0,0.0,0.0,0.0}};
double product[size][size],pi[size],diff;
int test;
int m=size;
int i j;
multiply(a,&m,product);
printf("\n");
printf((" \nThe product is:");
printf("\n");
for(i=0;i<m;i<m;i++)
{
printf("\n");
for(j=0;j<m;j++)
printf(" %15.12f", product[i][j]);
}
printf("\n");
printf("n");
return(0);
}
I tried to compile this and I got errors thank you for your input. I apologise for not posting this correctly yesterday.
|
|
|
|
|
belleissexy333 wrote: I tried to compile this and I got errors thank you for your input
It would really help if you post the exact error messages. They are there for a reason you know
Anyway, at first sight the block of for loops seems very strange...
|
|
|
|
|
The compiler tells you at what line the error occurs and what is the error. Could you please provide us this useful info?
Anyway, the following lines looks wrong:
belleissexy333 wrote: for(i=0;i<m;i<m;i++)
belleissexy333 wrote: for(j=0;j(* m;j++)
BTW: why the m parameter of the multiply function is a pointer (you always access just its value)?
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]
|
|
|
|
|
|
I just got this error yesterday with VS 2005. I thought it had been solved with SP1, but it hadn't. My solution was to access the class view from the header. Don't know why it worked.
|
|
|
|
|
I using Window CE API WriteFile() to write some barcode data to a file. Data is scanned and written to file ok. Problem is everything is on one line. How can I get the data in the file to be
line based. In other words, everytime I write to the file it writes a new line.
Thanks
|
|
|
|
|
Hi egerving,
The escape sequences for newline [^]in C/C++ is '\n'
Best Wishes,
-David Delaune
|
|
|
|
|
If Randor's suggestion doesn't work, you should try writing "\r\n".
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Using MFC & VC6
I am terribly confused about how to move CWnd objects around. With screen coords, client coords, dialog units, screen units, AaaRGh.
I have dialog app with button controls. From the OnSelect function of the buttons I am calling another popup dialog of my own making. I want to position the popup dialog so it obscure certain areas of the main dialog.
I am trying to use CWnd::MoveWindow() to move my popup dialog in the OnInitDialog() function to a position relative to the top left postion of the main dialog.
Which methods should I be using to get the main dialogs position to calculate coords for the MoveWindow() function in the correct units. A small example would be useful. Has anyone made a small Class to handle all this confussing translation between all the possible units and coordinte references ?
|
|
|
|
|
For that you want to use this route:
- Get the area of the main dialog that you want to obscure - this is most likely to be in client co-ordinates
- Convert to screen co-ordinates using CWnd::ClientToScreen[^]
- Now ensure that the child dialog covers that (screen co-ordinate) area. If you use MoveWindow, the screen co-ordinates are what you want to position the dialog
HTH!!!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Neil Urquhart wrote: I am terribly confused about how to move CWnd objects around. With screen coords, client coords, dialog units, screen units, AaaRGh.
I totally agree on that. Really understand your frustration..
Rozis
|
|
|
|
|
Hi i am new to vc++6.0 and i want to get menu item text which clicked by user.i tried with WH_GETMESSAGE hook and able to get menu item text for notepad,wordpad...but when i tried with vs2005 no WM_COMMAND is generating when i visit the menu item or clicked?
please tell me the way how we can get the menu item text for these application...is it not possible with hooking? from past one week i am searching for this...
Thanks in advance..
|
|
|
|
|
pashamsridhar wrote: Hi i am new to vc++6.0 and i want to get menu item text which clicked by user.
Which menu? One in an application you've written?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I already mentioned in my post i tried with vs2005..i want to get menu text when the user clicks any menu item in vs2005.
i am working with vc++6.0...please help me how to do this?
|
|
|
|
|
I suspect VS has non-standard menus (like Office….). I would use Spy++ (comes with Visual Studio) to see what messages ARE generated when you select a menu item.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
use this function for get the menu item text,
GetMenuString();
Copies the label of the specified menu item to the specified buffer.
int GetMenuString(
UINT nIDItem,
LPTSTR lpString,
int nMaxCount,
UINT nFlags
) const;
int GetMenuString(
UINT nIDItem,
CString& rString,
UINT nFlags
) const;
Regards,
Srinivas
|
|
|
|
|
I have installed mysql on my PC and created a database (sysops).
But I don't know how to connect and open the database.
I know how to use remote mysql, host (www...), user-name, password, database neme..,
What are connect info for local mysql?
Please help if you have experiences.
|
|
|
|