|
You want to check the format of dateString[] is YYYY-MM-DDThh:mm:ss?
As far as I remember, Visual Basic has isDate and isTime macros, but I don't think C has these! This leaves the brute force approach - check each component of the time individually, something like shown below.
BOOL bErrorFound = FALSE;<br />
if (dateString[4] != '-' || dateString[7] != '-' ||<br />
dateString[10] != 'T' || dateString[13] != ':' ||<br />
dateString[16] != ':' || strlen(dateString) != 20)<br />
bErrorFound = TRUE;<br />
else<br />
{<br />
}<br />
<br />
if (bErrorFound)<br />
giveMessage("bad Format String");<br />
else<br />
giveMessage("nice String");
|
|
|
|
|
I want to detect the system whether install a keyboard hook, how can i know?
Thanks in advance for your help
I love you not for whom you are, but who i am when I'm by your side
|
|
|
|
|
Hello everyone
Traditionally, unidymensional arrays are declared by providing the size of the array with a constant number as argument (e.g. myarray[size] where size is usually a const int ). I'm working building a model that needs arrays with one value per year (e.g. 6789 in 1989, 3992 in 1990 and so forth). In other words, I need to access values in the array when I have the year of interest as the index to identify the elements of the array. How can I declare the array as myarray(firstyear,lastyear) so I can access its elements the way I need and both firstyear and lastyear are read from a file?
Thanks
C.
|
|
|
|
|
Can u explain with some detail example
i cant get it
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi
Consider an array that could be indexed as:
int firstyear = 1980; <br />
int lastyear = 1985; <br />
<br />
<br />
int myarray(fistyear,lastyear)<br />
<br />
<br />
myarray[1981] = 6789;<br />
myarray[1983] = 3482;
// or work with a loop such as
for(int i = firstyear; i <= lastyear; i++)<br />
{<br />
myarray[i];<br />
}
This contrasts with the usual:
const int size = 6;<br />
int myarray[6];<br />
myarray[1] = 6789;<br />
myarray[3] = 3842;<br />
<br />
<br />
for(int i = 0; i < size; i++)<br />
{<br />
myarray[i];<br />
}<br />
Hope this makes it clearer.
Thanks for your help
C.
|
|
|
|
|
You could just do it like:
int i;<br />
for (i = 1980; i < 1985; i++)<br />
{<br />
array[i-1980] = 6370;
}
Just subtract the firstyear from the index, and you are there.
i = 1981;<br />
array[i-1980] = 200;
i = 1985;<br />
array[i-1980] = 220;
this is this.
|
|
|
|
|
Thank you, this certainly allows me to do what I need... although I was expecting a new way to declare the array instead of a clever way to work with what we already have... but hey, it works for me!
Cheers
|
|
|
|
|
I thing you can use map to implement your function!
have a lucky day.
|
|
|
|
|
Thanks for your suggestion. I was trying to avoid using containers. However, Mr. khan++ gave me an idea that solves my problem.
Cheers
|
|
|
|
|
Have you ever considered using the STL? And STL map would do it:
<br />
std::map<int,int> myArray;<br />
<br />
myArray[1981] = 6789;<br />
myArray[1983] = 3482;<br />
<br />
for ( std::map<int,int>::iterator iter = myArray.begin(); iter != myArray.end(); ++iter )<br />
{<br />
int key = (*iter).first;<br />
int value = (*iter).second;<br />
<br />
printf( "myArray[%d] = %d\n"), key, value );<br />
} <br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
-- modified at 3:36 Thursday 8th December, 2005
|
|
|
|
|
I meant to say:
myarray[size]
|
|
|
|
|
as i understand it, you have several arrays, one per year, and want to find them by the year number ; for this, the standard library implements the std::map<> class.
as I imagine, the arrays may not have the same size each, so you could be using such a map :
std::map< int, std::vector< int > > mapYearWithVector;
is this true ?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20] | soon : [VisualCalc 3.0]
|
|
|
|
|
I'm sure that this cannot be done using conventional arrays.
The way I would do it would be to use a linked list. That way, the years could be in any order, and years could be missed out if required.
class node
{
private :
int year;
int value;
node * pointToPrevious;
public :
node()
{
}
node(int y, int v, node * p)
{
year = y;
value = v;
pointToPrevious = p;
}
};
For fuller notes on linked lists as I teach it, please email me : simon.cornish@tesco.net
Regards
Simon
|
|
|
|
|
In my application i get body(IHTMLElement) and try to reset onclick event like javascript:alert('ok');
There is little document of IHTMLElement->put_onclick(VARIANT) from MSDN, but the line
CComPtr<ihtmlelement> pBodyElement;
//other codes
pBodyElement->put_onclicke(VARIANT("javascript:alert('ok');"));
doesnot work.
Would you please show me why,or show me some samples?
thanks advance.
|
|
|
|
|
Hi,
I am using CRecordset to retrieve data from SQL server but i found there is a performance issue with retrieving 173 rows of data from the data. I then narrow it down to MoveNext() causes the performance to be slow. Can someone please help?
Here is the code, simple but slow in performance.
CString sSql;
CRecordset rs(&gGlobalLHdb);
sSql = "SELECT * FROM metrics";
if (!sSql.IsEmpty())
{
rs.Open(CRecordset::forwardOnly, _T(sSql));
while(!rs.IsEOF())
{
// metric_name
CString s1;
s1 = "metrics_name";
CString sRetVal1;
rs.GetFieldValue(s1,sRetVal1);
rs.MoveNext();
}
rs.Close();
thank you so much,
Sue
|
|
|
|
|
I have yet to understand why I should choose Tabbed Controls over Property Sheets and vice-versa. Are there advantages of one over the other? How do they differ from a user's point of view?
Any short answers to these questions?
Thanks in advance.
P.S. The answers may be obvious, but I somehow missed the outstanding
diferences.
|
|
|
|
|
I have SnapStream which records TV shows in MPG then compresses to WMV format. I also have an iPod Video which wants MP4. Unfortunately I can't find anything that will automatically, or from a command line batch file, find new recordings and convert them. Hmm, this sounds like a good project to start on.
I'm pretty well versed in C++ and know C# just a little bit less. I searched the articles for a library/API/SDK to interface with but didn't really find anything useful. Can anyone direct me to some articles, or SDKs, to help get me started writing my own file conversion program? Am I on crack thinking I can just jump into multimedia conversion with only experience writing MSI installs and network programs?
Thanks in advance for any knowledge of this you can impart to this humble dev.
|
|
|
|
|
DirectShow, which is part of DirectX.
davedoc wrote: Am I on crack thinking I can just jump into multimedia conversion with only experience writing MSI installs and network programs?
Perhaps, only time will tell.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks. I've downloaded and installed.
Onto happy reading/learning...
|
|
|
|
|
How do you like SnapStream? I'm still using the crappy stuff that came with an ATI All-In-Wonder card. It works okay, but there's stuff about it that I dislike. The TV listings app is to closely tied to TV viewing. The dialog for recordings should be modeless instead of modal. Simple stuff, but it bugs me. Thanks.
Chris Meech
I am Canadian. [heard in a local bar]
Remember that in Texas, Gun Control is hitting what you aim at. [Richard Stringer]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
It's worth every penny of the $50 I paid for it 3 years ago. I've been using Snapstream since their late 2.x days, it's now at 4.0, and I've been in love with the software ever since. I recommend it to all the TiVo users I know Once you pay for the software...that's it. No monthly subscriber charge.
I saw some bugs at the 2.x level but the support forum they have on their site has always been quick to respond. I'm still running the latest 3.x build and it's rock solid. The upgrade to 4.x will cost me another license purchase and I haven't upgraded this yet.
I stream TV (news channel) to my work using Snapstream and have it playing in the background.
|
|
|
|
|
Thanks. Good stuff to hear.
Chris Meech
I am Canadian. [heard in a local bar]
Remember that in Texas, Gun Control is hitting what you aim at. [Richard Stringer]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
I have a CEdit which I drawn a custom background for in an WM_PAINT handler. it works great until I edit, then it draws like any other edit control. If I put an Invalidate() call in my WM_CHAR handler, it draws the background properly, and draws the text all wrong. What should I be doing here ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Not that I have ever done it, but you could try drawing the background in OnEraseBkgnd, and in OnCtlColor call pDC->SetBkMode(TRANSPARENT) and return a NULL brush so that the text is drawn transparently over your background.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Sounds like a great idea, I'll try that. I was going to go for the Erase Background, but I hadn't thought of how to stop the control drawing over it. The edit control apparently draws outside of WM_PAINT a LOT.
Christian Graus - Microsoft MVP - C++
|
|
|
|