|
It solves the following equation for X.
{stop time} + {X} = {start time}
If you walk through examples by hand you will see that the code appears to solve that equation correctly.
However like the other response I too find it counter intuitive.
As noted in the other response the expected difference would be to subtract start from stop. This solution ends up with negative values.
It also treats a time period on a fixed clock - one that does not cross midnight. Which is nonsensical in human terms.
|
|
|
|
|
jschell wrote: {stop time} + {X} = {start time} Really? Only if X is negative; or the interval stops before it starts.
|
|
|
|
|
Richard MacCutchan wrote: Only if X is negative;
It is negative.
|
|
|
|
|
yes i find that problem too....
|
|
|
|
|
I have noticed that CMainFrame::ActivateFrame is not called normally, when I start the app from debugger, or from Windows Explorer.
void CMainFrame::ActivateFrame(int nCmdShow)
{
MessageBox(_T("AAAA"));
CMDIFrameWnd::ActivateFrame(nCmdShow);
}
And I have read CFrameWnd::ActivateFrame
[^]here that this method are called "Call this member function to activate and restore the frame window so that it is visible and available to the user. This member function is usually called after a non-user interface event such as a DDE, OLE, or other event that may show the frame window or its contents to the user."
Can you give an example when this method is called ? I am trying to start the my app in hidden mode, passing in this method (CMainFrame::ActivateFrame) nCmdShow = SW_HIDE;
Thank you.
|
|
|
|
|
Flaviu2 wrote: I have noticed that CMainFrame::ActivateFrame is not called normally, when I start the app from debugger, or from Windows Explorer.
void CMainFrame::ActivateFrame(int nCmdShow)
{
MessageBox(_T("AAAA"));
CMDIFrameWnd::ActivateFrame(nCmdShow);
}
Did you try to replace MessageBox call with a TRACE and check whether your text is displayed in the Output window?
|
|
|
|
|
Yes, I have:
void CMainFrame::ActivateFrame(int nCmdShow)
{
TRACE(_T("======================================================AAAA\n"));
CMDIFrameWnd::ActivateFrame(nCmdShow);
}
and there is no trace in output window ...
|
|
|
|
|
I want to create schema file xsd file programmatically in c++ so that i can add validation information for each element and read back the tree structure with validation.
Is this possible in c++?
|
|
|
|
|
Yes, of course it is possible, assuming that you understand how to create the schema in the first place. Take a look at some of the links at: create xsd schema - Google Search[^].
|
|
|
|
|
I wanted to programmatically create/read xsd file in c++?
We have lot of tools to generate xsd from xml and vice versa...
We also have lot of example in .net but wanted it in c++ code.
I am using msxml6 to parse xml files and wanted to do the same for xsd files aswell.
|
|
|
|
|
Fine, that is what you want. But what problem are you having with your code?
|
|
|
|
|
I am unable to write c++ code to parse XSD files.
Very less resources to begin with.
|
|
|
|
|
That seems a bit odd.
The normal process for using an xsd would be as follows.
1. Create the xsd manually.
2. Create program to accept xml as input
3. Validate the input from 2 using 1.
Nothing it the above really has anything to do with a "tree'.
One can use the xsd to automatically generate classes which can be used to parse and consume the input. At least in my experience validating the input that way (exclusively in terms of the xsd) doesn't lead to very useful errors. However using the xsd itself as a input along with the xml leads to better errors. But that could have had to do with the generation framework that I was using.
|
|
|
|
|
This is my task in vc++
- To create GUI for user to add tree structure where each tree node can contain attribute, restrictions etc..
- Once user configures we write it to xsd files.
- If user want to alter he reopens xsd file and alters any properties of xsd file.
possible?
|
|
|
|
|
brraj wrote: possible?
Of course.
An XSD is just an XML file with a certain format.
So map the 'attributes' allowed in your app to appropriate constructs in an XSD. You generate the xsd using the same framework that you would for xml.
|
|
|
|
|
It is observed memory will be allocated for a structure only when a structure variable is declared.
But when I tried this program, it printed address:
#include<stdio.h>
struct emp{
int age;
char name[30];
}emp1;
main()
{
printf("%p is the address\n",&emp1.name);
}
Why ?
modified 28-Dec-17 2:21am.
|
|
|
|
|
Because you have declared the variable emp1 . As I have suggested to a number of other people recently, please get hold of a C language study guide and learn, at least, the basics of the language.
|
|
|
|
|
Is it a generational thing? It seems more and more that folks are jumping right into chapter 7 of the book and then getting completely lost when things from the previous 6 chapters are being referenced and they can't understand why or where they came from.
"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
modified 28-Dec-17 12:14pm.
|
|
|
|
|
It seems to be, and we are seeing more and more of this type of question here. I guess they have all bought into the idea that you can make a lot of money as a developer with minimal training. Just pray they are not working at your bank or local hospital.
|
|
|
|
|
here is the code i have wrriten but when reaching the for()loop it just skips though the first loop of for( i.e. i=0 )and starts with i=1. What is wrong in the code.
#include <stdio.h>
#include <string.h>
int main()
{
int i, log, k, c1=0, c2=0, j=0;
char team_1[100], team_2[100], input[100], ch;
printf("Enter name of Team-1: \n");
gets(team_1);
printf("Enter the name of Team-2\n");
gets(team_2);
if(strcmp(team_1, team_2)==0)
{
printf("Oops! both names are same. Please enter again: \n");
while(strcmp(team_1, team_2)==0)
{
printf("Enter name of Team-1: \n");
gets(team_1);
printf("Enter the name of Team-2\n");
gets(team_2);
}
}
printf("Enter the number of logs: \n\n");
scanf("%d", &log);
for(i=0; i<log; i++)
{
printf("Enter log-%d\n", i+1);
gets(input);
if(strcmp(input, team_1) == 0)
c1++;
else if(strcmp(input, team_2) == 0)
c2++;
for(k=0; k<=strlen(input); k++)
{
input[k]=0;
}
}
if(c1>c2)
printf("Team-1 wins");
else
printf("Team-2 wins");
return 0;
}
|
|
|
|
|
Tarun Jha wrote: when reaching the for()loop it just skips though the first loop of for( i.e. i=0 )and starts with i=1
How did you find out it? Did you debug your code? Then what are the values of i and log right before stepping in the loop?
|
|
|
|
|
This is the output
Enter name of Team-1:
rob
Enter the name of Team-2
max
Enter the number of logs:
5
Enter log-1
Invalid entry !
Enter log-2
max
Enter log-3
max
Enter log-4
rob
Enter log-5
max
Team-2 wins
Process returned 0 (0x0) execution time : 23.573 s
Press any key to continue.
|
|
|
|
|
Tarun Jha wrote: Enter the number of logs:
5
Enter log-1
And there is your code:
for(i=0; i<log; i++)
{
printf("Enter log-%d\n", i+1);
So why do you think the loop skips when i is zero??? It works and prints the result
"Enter log-1"
|
|
|
|
|
no, it doen't take input for first loop, it just skips to the second one, does'nt matter from where i is initialized.
Please run the code you will understand.
|
|
|
|
|
Why are you asking for both team names if they are equal? You already have team_1 name so you only need a different name for team_2 . You do not need to clear the input array as it will get overwritten on the next gets call. And it skips the first loop because scanf leaves a newline character in the input buffer which then is consumed by the first call to gets . If you did as I have suggested elsewhere you could figure all these things out for yourself.
|
|
|
|