|
Hi!
Your solution were good. It made me think in another way. But there is one problem.
How will I solve microseconds (6 digits)?? Two digits is one byte, so six digits willbe 3 byte??
|
|
|
|
|
styve wrote:
I will have it in ascii format, because it take less space in a file
Any ways if you want to store 'A' in the file what do you want to store
'A' or '65' (65 is ascii for 'A') which one takes more space ???
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
One letter or one digit that is stored to a file is one byte.
If I only store A, the file is one byte.
If I store 65, the file is two byte.
It was that I meant
|
|
|
|
|
styve wrote:
If I store 65, the file is two byte.
Not necessarily. Consider this:
FILE *f;
char letr = 'A';
fwrite(&letr, sizeof(char), 1, f);
letr = 65;
fwrite(&letr, sizeof(char), 1, f); The size of the file in both cases will be one byte.
char *ltrs = "65";
fwrite(ltrs, sizeof(char), 2, f); Now the size of the file will be two bytes.
int num = 65;
fwrite(&num, sizeof(int), 1, f); Now the size of the file will be four bytes.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
hi
i have inserter ms web browser acticeX in my project. mr.Sargoytchev told me that if i want to get the source code of the html that is showing by this activeX u should do the following steps:
1. Use the IWebBrowser2::Document property to obtain an IDispatch interface to the DOM document. <br />
<br />
2. Query the obtained IDispatch for IHTMLDocument3. <br />
<br />
3. Use the IHTMLDocument3::createTextNode() method to convert the root node to text.
first how can i get IWebBrowser2 pointer for my ActiveX window.
for example my activeX class is CExplorer1. and my variable is : CExplorer * web1;
here is my code for step one (Correct me if i'm wroing):
IWebBrowser2* pWebBrowser;
IDispatch* pHtmlDoc = NULL;<br />
HRESULT hr = pWebBrowser->get_Document( &pHtmlDoc );
but i cant write the code to Query the obtained IDispatch for IHTMLDocument3.
any idea ?
thanx.
|
|
|
|
|
hello
I have created a windows application with visual c++ 6.0 which connects to a database.
The application executes SQL queries and I want to set some triggers or the insert, update and delete queries.
However, Where should i place my triggers?
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=s",sDriver,sFile);
TRY
{
CDatabase ComboDatabase;
// Open the database
ComboDatabase.Ope(NULL,false,false,sDsn);
// Build the SQL statement
SqlCommand = "INSERT INTO BandSetting "
"VALUES('" + str25 + "'" ",'" + str1 + "'" ",'" + str2 + "'"
",'" + str3 + "'" ",'" + str4 + "'" ",'"+ str5 + "'" ",'"+ str6 + "'" ",'" + str7 + "'" ",'" + str8 + "'" ",'"+ str9 + "'" ",'" + str10 + "'" ",'" + str11 + "'" ",'"+ str12 + "'" ",'" + str13 + "'" ",'" + str14 + "'" ",'" + str15 + "'" ",'" + str16 + "'" ",'" + str17 + "'" ",'"+ str18 + "'" ",'" + str19 + "'" ",'" + str20 + "'" ",'"+ str21 + "'" ",'" + str22 + "'" ",'" + str23 + "'" ", + str24 + "'" ")" ;
ComboDatabase.ExecuteSQL(SqlCommand);
// Close the database
ComboDatabase.Close();
}
where do i put the trigger???
hope you guys can help me out on this! thanks (^_^!!)
|
|
|
|
|
Now ppl this is funny!
int var=10;<br />
cout<< (var++ * var++) ;
it should print 110 but it actually doesn't. it prints 100
but it works correctly (prints 110) on c#, java compilers and other c++ compilers.
|
|
|
|
|
i get 102 when i run it
|
|
|
|
|
With VC++ 6.0, the result here is
100. (One hundred.)
And I think "One hundred" is a correct result. Because when such an expression:
int var = 10;
cout << (var++ * var++);
is equal to:
int var = 10;
cout << (var * var);
var = var + 1;
var = var + 1;
// var = 12 now.
<b>Maxwell Chen</b>
|
|
|
|
|
Yes even i do get 100
Cos v++ is equivalent to a post increment so the answer should be v*v & the value of v is then updated to 12
|
|
|
|
|
No I don't think so, the results should be 110 because unary operators has higher precedence over binary operators, the correct steps will be as follwing:
At the beginning var is 10.
1, calc the first "var++ ", result is 10 and var becomes 11.
2, calc the second "var++ ", result is 11 and var becomes 12.
3, calc the product of the first result(10) and the second result(11), which is 110.
At the end var is 12.
|
|
|
|
|
Maxwell Chen is right. The result should be 100.
Post-Increment means "Increment this variable after the operation the post-increment is used in".
So a = b++ means "A = B. Increment B."
and a= b++ * c++ means "A = B multiplied with C. Increment B. Increment C."
Cheers
Sebastian
|
|
|
|
|
u know * is Preeminent than ++ so at first RESULT will set to (Var * Var).
but var++ will not change the result
so result = (10*10) = 100
and val will updated to 12
|
|
|
|
|
You might be confused...
Regarding to the example:
cout << (var++ * var++);
The meaning of "precedence" is, to take the expression as:
cout << ((var++) * (var++));
// Means that parsing the postfix ++ token first.
// Not means that counting the result of postfix ++ operation.
rather than
cout << ((var++) (*var)++); // Wrong.
since operator * (Multiplicative) has lower precedence than operator ++ (postfix).
<b>Maxwell Chen</b>
|
|
|
|
|
Ok I see. You are right, sorry about the confusion.
|
|
|
|
|
Maxwell Chen
|
|
|
|
|
C++ only guarantees that all side-effects are complete by the point that a sequence point is reached.
All function arguments must be evaluated before a function is called, but order of evaluation of the function arguments is implementation-defined. Visual C++ clearly evaluates var once, then performs the multiplication, then the post-increments. This looseness allows the compiler to produce more optimal code in some circumstances.
C# and Java have strict left-to-right evaluation, so your code does work as you are expecting with those languages.
|
|
|
|
|
nicely explained but i am still not completely satisfied just because when i implement my own class "myint" which has the post increment, the multiplication and the assignment operators overloaded and i use them as:
myint a(10);<br />
myint c=(a++ * a++);
i get value of c as 110
but when i use int i.e:
int a=10;<br />
int c=(a++ * a++);
i get c as 100
why this???
secondly in the case of cout<<(a++ * a++) u can say that (a++ * a++) comes under the case of "evaluation of function order" (though i don't agree) but when we use
int c=(a++ * a++) ;
it does not come under "evaluation of fuction order" it comes under "operator precedence" case, and it seems as if vc++ is voilating some rules.
for ur information the "evaluation of function order" case is as:
int a=1;
cout<
|
|
|
|
|
The C++ standard (ISO 14882:1998) at section 5, paragraph 5 reads:
Except where noted, the order of evaluation of operands of individual operators and subexpressions of individual expressions, and the order in which side effects take place, is unspecified. Between the previous and next sequence point a scalar object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored. The requirements of this paragraph shall be met for each allowable ordering of the subexpressions of a full expression; otherwise the behavior is undefined.
Example:
i = v[i++];
i = 7, i++, i++;
i = ++i + 1;
i = i + 1; All that C++ guarantees is that the side-effects of evaluating an expression are complete by the next sequence point - it does not specify an order of evaluation of terms in an expression, except where operator precedence is involved. The second example above works because the comma operator introduces a sequence point.
The exact text in the standard regarding sequence points is in section 1.9, paragraph 7, and reads: Accessing an object designated by a volatile lvalue (3.10), modifying an object, calling a library I/O function, or calling a function that does any of those operations are all side effects, which are changes in the state of the execution environment. Evaluation of an expression might produce side effects. At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place.
However, an overloaded operator is treated in the same way as a function call. There is a sequence point between evaluating the arguments for a function call and the actual call itself, and at the end of each statement. In the case of myint , the compiler essentially generates:
myint c = (a.operator++(int)).operator*(a.operator++(int)); The two calls to operator++ are therefore executed before the call to operator* .
In the second case I would argue that the compiler appears to have generated the wrong code, because function calls are being generated, and << is left-associative. Again, the mapping is something like:
((cout.operator<<(a++)).operator<<(a++)).operator<<(a++) I would have expected the side-effect of the first increment to be complete before the second argument was evaluated. However, this is where my understanding of the standard becomes a bit hazy. If you want a genuine expert, ask on the comp.lang.c++.moderated newsgroup. All I can tell you is that Visual C++ 6 and Visual Studio .NET 2003 agree in a Debug build. For a release build, VC6 outputs "321"; VC7.1 outputs "111".
|
|
|
|
|
Modifying var more than once between sequence points results in undefined behavior in C++. A C++ compiler can generate whatever results it wants from this. You could get 100, 110, 121, or any other value. Any result produced can't be considered correct or wrong - it is undefined.
|
|
|
|
|
if the program is:
int var = 10;
cout<<(var++ * var++);
the result is 102
and if the program is like this:
int var = 10;
cout<<((var++)*(var++));
the result is 100;
what i think is first the mutiplication operation is being taken place and the varible is getting incremented.
in vc++ programming guide present in MSDN library
unary operator (post increment) has the highest precedence
ok
u know the problem y it is happening
pls send a mail
|
|
|
|
|
Grey the background of a CListBox on the selection of a button,
Currently using WM_CTLCOLOR returing diff brushes work. But I have the style Extended for the ClistBox. with this style. when I grey out the list, if the list has items it wil grey only that part of the list that is empty. The filled part still has the Background as white
The below code will work for Single selection style, but not for extended style.
HBRUSH CTestaDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
//Set background transparent
pDC->SetBkMode(TRANSPARENT);
if (pWnd->GetDlgCtrlID() == IDC_MYLISTBOX)
{
if(m_bGrayed)
return (HBRUSH)GetStockObject(GRAY_BRUSH);
else
return (HBRUSH)GetStockObject(WHITE_BRUSH);
}
return hbr;
}
void CTestaDlg::OnRadio1()
{
m_bGrayed = FALSE;
m_MyListBox.EnableWindow(TRUE);
}
void CTestaDlg::OnRadio2()
{
m_bGrayed = TRUE;
m_MyListBox.EnableWindow(FALSE);
}
|
|
|
|
|
i need to know how to share on Dll with multiple client
any link or tutorial which focus on these isuue would be appreciated
thanx
|
|
|
|
|
Do you have access to the DLL code. If yes i cud give u pointers.
Else try to find out if the dll is thread safe where multiple client can access it
Dimple
|
|
|
|
|
Thanx 4 reply dimple
i refered one book where i read,u can share the dll with memory mapping to access multiple client
like
#pragma dat_seg()
but i no idea how to implement that one.
can give me some idea
thanx
|
|
|
|
|