|
Sorry, but you're not helping at all. I do understand it. I understand what the compiler does. I know it processing the c++ code, converts it into machine code, creating object files, and then links them into the executable. The thing I did not understand was how the final product would run if there were multiple sources(these are also known as source files or .cpp files). I was attempting to see if when the final product was executed if the functions from each separate source would run along side one another, or if it worked the same as having multiple functions within one single .cpp file. So instead of judging my understanding of the process, try being helpful like the other fellow.
|
|
|
|
|
gamefreak2291 wrote: I know it processing the c++ code, converts it into machine code, creating object files, and then links them into the executable
gamefreak2291 wrote: The thing I did not understand was how the final product would run if there were multiple sources
This is a contradiction...
You miss some aspects of the first point that makes you not having a proper understanding the second.
I try to summarize in brief:
- Each cpp file is a set of declaration that can be either object instances (aka "global variables") or function ("sequence of expressions and statements") each having a name.
Some of those declaration are "external" other "internal" (by default, functions are "external", tgat means "visible outside the file they are in")
- The translation the compiler does on each cpp file produces obj files where code is translated into machine code, and where external names are mapped in a symbol table.
- The linker peeks all the obj-s and libraries and resolve the mapped names with their respective references they have.
To let this process to succeed, all linked names must be unique (or mangled as such).
One of the names (corresponding to the main function)is then mapped in the exe file as the "applicaion entry point" (well, not exacly, the entry point is an internally CRT initializer that calls main at the end...) so that when the operating system loads the application the execution will start from there.
If you follow these three steps, there is no reason why your question should take place.
The program flows in the way the various functions reciprocally call each other. No matter where they originally came from.
There is no "parallelism" in a C++ classic program.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
The question should still exist, however it could have been slightly more direct. I understand how having multiple functions and variables withing a single .cpp work. I know extra functions must be called, from within the main function, to be 'executed'. I, however, did not understand how things would work having multiple .cpp files all with their own "main functions" because I had never been instructed, read about, or tried this before. Cedric Moonen understood exactly what I was doing wrong, made mention of it, and my confusion of how having multiple .cpp files work. I now understand it's used for organizational purposes, and works no differently that having multiple functions within one file. Nevertheless I appreciate the attempt at helping me.
|
|
|
|
|
gamefreak2291 wrote: I, however, did not understand how things would work having multiple .cpp files all with their own "main functions" because ...
After I told that in all a program (no matter with how many files) names bust be unique, the question become meaningless:
What is the meaning (in mathematical sense) of the words "main functions"?
If you link more file having each one a main function, the result is a linker error.
You have never been instructed about how to do that, simply because it cannot work.
Anyway, it doesn't matter how: the important thing is that you understood what was the problem.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Hi All
After long search on net i found formula.
I have find formula Permutations with repetition on net
n^r Where n=length of string and r=combination choice
I want to make combination according to this formula n^r.
According to this formila n^r=9 combination possible here like this
AA
AB
AC
BB
BA
BC
CC
CA
CB
Here i am trying but stuck in inner loop.
void CTestCombDlg::OnBnClickedOk()
{
CString acc="abcd";
int r=2;
for(int i=0;i<2;i++)
{
int nl=2*r;
for( int k=0;k<nl;k++)
{
}
}
}
|
|
|
|
|
You can produce the sequence (in slight different order) this way:
#include <stdio.h>
#include <string.h>
int main()
{
const char sSequence[]="abcd";
int len;
len = (int) strlen(sSequence);
for (int i=0; i<len; i++)
for (int j=0; i<len; j++)
printf("%c%c\n", sSequence[i], sSequence[j]);
}
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 don't understand what you want to say through code?Can you say something more detail.
Thanks
modified on Tuesday, April 6, 2010 4:07 AM
|
|
|
|
|
The code produces the sequence you need, doesn't it?
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]
|
|
|
|
|
Sorry yes i need it.
Thanks
|
|
|
|
|
Hello sir
when i try to make combination of 3char then whats approach you advice me.
Example;
"ABC"
{a,a,a} {a,a,b} {a,a,c} {a,b,a} {a,b,b} {a,b,c} {a,c,a} {a,c,b} {a,c,c} {b,a,a} {b,a,b} {b,a,c} {b,b,a} {b,b,b} {b,b,c} {b,c,a} {b,c,b} {b,c,c} {c,a,a} {c,a,b} {c,a,c} {c,b,a} {c,b,b} {c,b,c} {c,c,a} {c,c,b} {c,c,c}
Please help me
|
|
|
|
|
My advice is: go recursive.
However, I guess you need an example:
#include <stdio.h>
#include <string.h>
void step(char sSeq[], int len, char sOut[], int level, const int depth)
{
for (int i=0; i<len; i++)
{
sOut[level-1]= sSeq[i];
if ( level == depth)
printf("%s\n", sOut);
else
step(sSeq, len, sOut, level+1, depth);
}
}
int main()
{
char sSeq[]="ABC";
int len = strlen(sSeq);
const int DEPTH = 3;
char sOut[DEPTH+1]={'\0'};
step(sSeq, len, sOut, 1, DEPTH);
return 0;
}
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]
|
|
|
|
|
Sorry for late reply..
Thanks....
You solve my big problem..
|
|
|
|
|
You are welcome.
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]
|
|
|
|
|
Hi all,
i m open CFileDialog to browse file,
in this manner " CFileDialog fileDlg(TRUE, NULL, NULL, OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_OVERWRITEPROMPT,_T("Text Files|*.txt|Excel Files|*.xls;*.xlsx|"));
"
some time it works but some times it become not responding and crash on Windows server 2008.
please help me what can i do.
thanks for help in advance.
|
|
|
|
|
xlsx|")); is missing the end-pipe => xlsx||"));
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Now i m chk it with "||" end pipe.but still problem is exist.
and diaplay these details in more info:
<br />
Problem signature:<br />
Problem Event Name: APPCRASH<br />
Application Name: Test.exe<br />
Application Version: 6.0.1.4<br />
Application Timestamp: 4bbd6e29<br />
Fault Module Name: Secur32.dll<br />
Fault Module Version: 6.0.6001.18000<br />
Fault Module Timestamp: 4791a777<br />
Exception Code: c0000005<br />
Exception Offset: 000021b3<br />
OS Version: 6.0.6001.2.1.0.274.10<br />
Locale ID: 1033<br />
Additional Information 1: 98e2<br />
Additional Information 2: 6076d0439494b3c22f752162dd29dcbf<br />
Additional Information 3: 4f76<br />
Additional Information 4: e360291dec91efb6c8036cc8226e0089<br />
<br />
Read our privacy statement:<br />
http:
<br />
please help me.
|
|
|
|
|
it looks strange like "dll hell".
Check for actual dlls on the server and you dev-pc. Consider static linking.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I have trouble with declaring my array size so as to avoid the stack overflow error:
_variant_t raw_data[10000][100]
_variant_t results[10000][100]
i read somewhere about dynamic sizing, i tried this but it didnt work
_variant_t *raw_data = new _variant_t [10000][100]
any help would be very much appreciated..
|
|
|
|
|
buki86 wrote: i read somewhere about dynamic sizing, i tried this but it didnt work
Why not?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
IIRC stack space is limited to 1MB, so you can't create a stack-based array holding 1M elements. You could dynamically allocate it though, using malloc() or new.
|
|
|
|
|
I'm going by memory, too, but I think the default stack is 1 Meg but you can set it to be a different size as part of the build. I've never personally done it though.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Tim Craig wrote: but you can set it to be a different size as part of the build.
yeah, that is very plausible, however I never have done so for a Windows app.
|
|
|
|
|
Tim Craig wrote: but you can set it to be a different size as part of the build.
yeah, that is very plausible; it is common practice for embedded systems, however I never have done so for a Windows app.
|
|
|
|
|
You remember well [^].
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 remember a poem in Mad Magazine in the late 50's that went "I remember, I remember...", but I can't remember what they remembered.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|