 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Every time I see a program I really want to know how it works. For example
for(x=0; x<=2; x++)
tracing...
x=0 0<=2 TRUE
x=1 1<=2 TRUE
x=2 2<=2 TRUE
x=3 3<=2 FALSE
There are some programs that I find it difficult to trace and how can I trace it even if it is hard to trace what I mean is how to determine the flow of the program? I just want to understand the algorithm of the program created by me and by others.
|
|
|
|
 |
Step through the code using the debugger (VS?), or write to the output window of the debugger (eg. OutputDebugString()), or write to a log file? There are probably other ways as well.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
 |
Hi, I am trying to read program flash on a pic18f67k22.
From the datasheet...
"The TBLRD instruction is used to retrieve data from
program memory and places it into data RAM"
example in ASM...
TBLRD*+
How do I execute "TBLRD*+" in 'C'?
- Thanks
“If I had asked people what they wanted, they would have said faster horses.”
― Henry Ford
|
|
|
|
 |
Check out the documentation of the compiler you are using, possibly it provides a builtin function for this very purpose (for instance, the C30 compiler, for PIC24 devices, has something like that). As an alternative method you may always use inline assembly instructions in the C code (as far as I know all the PIC compilers support inline assembly). In any case, read carefully the compiler's documentation.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
 |
Thanks CP.
“If I had asked people what they wanted, they would have said faster horses.”
― Henry Ford
|
|
|
|
 |
You are welcome.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
 |
Perhaps use inline assembler, employing the _asm and _endasm directives?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
 |
I've to do the searching process through the 2-3 tree by storing the roll number s of the students as keys in the tree. The tree node will contain a pointer to the doubly node in the doubly linked list.
I included the doubly node pointer as a private member in the tree node class
Then tried to merge the 2-3 tree nodes with the student objects
Node<Student> *s1,*s2,*s3,*s4;
s1 = new Node<Student>;
s1->data.setData("Hamza",12105092);
s2 = new Node<Student>;
s2->data.setData("Sherlock",12105102);
s3 = new Node<Student>;
s3->data.setData("Watson",12105022);
s4 = new Node<Student>;
s4->data.setData("Spidey",12105042);
Course c1("OOP",3.52,"A");
Course c2("DM",4,"A+");
Course c3("DLD",3.2,"A-");
CTree<Student> *tree1;
tree1 = new CTree<Student>();
tree1->insert(new Student("",12105092));
tree1->insert(new Student("",12105042));
tree1->insert(new Student("",12105102));
tree1->insert(new Student("",12105022));
tree1->findOWN(new Student("",12105092))->merge(s1);
tree1->findOWN(new Student("",12105102))->merge(s2);
tree1->findOWN(new Student("",12105022))->merge(s3);
tree1->findOWN(new Student("",12105042))->merge(s4);
doublyLinkedList<Student> d1;
d1.insert(s1);
d1.insert(s2);
d1.insert(s3);
d1.insert(s4);
Relevant 2-3 tree methods
template<class T>
CNode<T>* CTree<T>::findOWN(T*pKey)
{
CNode<T> *pNodeFound= 0;
bool bKeyFound = false;
search(pKey, &pNodeFound, &bKeyFound);
if(bKeyFound == true &&
TCompare(pKey, pNodeFound->getSmallKey()) == EQUAL)
{
return pNodeFound;
}
else if(bKeyFound == true &&
pNodeFound->getSize() == threeNode &&
TCompare(pKey, pNodeFound->getBigKey()) == EQUAL)
{
return pNodeFound;
}
else
{
return 0;
}
}
template<class T>
int CTree<T>::TCompare(const T* const pT1, const T* const pT2) const
{
int iReturnCode = FAILURE;
if(*pT1 < *pT2)
{
iReturnCode = LESS;
}
else if(*pT2 < *pT1)
{
iReturnCode = GREATER;
}
else
{
iReturnCode = EQUAL;
}
return iReturnCode;
}
1. Some how the merging's aren't completely right e.g in case where there are two key values in a node then it mixes up the merging when I try to search 12105022 I should be getting "Watson" but I get "Spidey" instead, how to fix that?
|
|
|
|
 |
Hamza Bin Amin wrote: ...it mixes up the merging when I try to search 12105022 I should be getting "Watson" but I get "Spidey" instead, how to fix that? So have you single-stepped through the code using the debugger?
"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
|
|
|
|
 |
I suppose you should show the complete code in order to get help.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
 |
Message Automatically Removed
|
|
|
|
 |
Member 10914803 wrote: Due to the sensitive nature of this project and the intellectual properties involved, we prefer to keep our exposure to a minimum. Thus, if you're interested in possibly getting involved then please reply here... "That's funny right there!" -- Mater
"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
|
|
|
|
 |
Member 10914803 wrote: keep our exposure to a minimum
The Backroom[^] would meet your requirement.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
 |
Member 10914803 wrote: I am a seasoned Software Engineer
Does that mean you are covered with herbs and spices?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
 |
Hello guys. I am trying to make and use a dll in VC++. I am following this sample. The dll compiles successfully. But when I try to integrate it's .dll, .lib and .h files in another project, then it gives me 5 linker errors. One of them is Error LNK2019 and rest are Error LNK2001. Couple of them look like this
1 - error LNK2019: unresolved external symbol "public: __thiscall CMyClass::CMyClass(void)" referenced in function "public: __thiscall CClientDlg::CClientsDlg(class CWnd *)"
2 - error LNK2001: unresolved external symbol "public: __thiscall CMyClass::~CMyClass(void)"
Just to let you know, I make a new folder and put all the said files in it. Then I add this path to the following properties
+ Properties-> Linker-> General-> Additional Library Directories
+ Properties-> C/C++-> General-> Additional Include Libraries
What could I be doing wrong here? Thanks for any pointer.
|
|
|
|
|
 |
Is that one of your export classes? ...how is it defined in the header? ...make sure you've labeled it as an import (that's the declspec part of the example) in the header file.
One thing I noticed about that example is that it's exporting functions, not really exporting classes. Difference is the constructor, if you're exporting/importing a whole class, this[^] is the way to do it. Look at the section labeled as "C++ Native Approach: Exporting a Class".... although it wouldn't hurt to read the whole article so you know get as much info as possible.
|
|
|
|
 |
I am using a Windows host machine to cross compile programs on to a Linux RT platform using a GCC cross compiler.
Assume, the C program I write, links to a shared library libShared.so as I am using functions defined in that library inside my program.
In the Eclipse editor I am providing the library name (libshared.so), and its path under linker options. Now when I compile the program, I get compilation errors since libShared.so links to multiple other libraries (eg: lib11.so, lib12.so, lib13.so), but I am not explicitly calling any functions from these libraries.
My question is, Why should the compiler generate errors, when I don't explicitly use functions defined in those libraries ?
However when I specify the name and path of the libraries liked by libShared.so, the compilation passes.
|
|
|
|
 |
Quote: Why should the compiler generate errors, when I don't explicitly use functions defined in those libraries ? Because libShared does.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
 |
I know that if you allocate an object on the heap using 'new', it needs to be deleted.
But what if it's a function that returns a pointer to an object?
For example...
SomeClass *someClass = aFunction();
I'm assuming that inside of aFunction(), there is a 'new Someclass()' in there somewhere.
However... When I delete someClass on app exit, the app crashes. If I comment out the
delete, it exits ok. But won't there be a memory leak if someClass isn't deleted?
|
|
|
|
 |
it's impossible to say.
is aFunction returning a pointer to a global, or to an object that is it managing somehow ?
|
|
|
|
 |