Can someone tell me how to write
void readBinaryTree(BinaryTree *&p, ifstream &fin) {
in C
...
`void readBinaryTree(BinaryTree **p, ifstream *fin) {`
`readBinaryTree(&p, fin)`
???
Thanks
Can someone tell me how to write
void readBinaryTree(BinaryTree *&p, ifstream &fin) {
in C
...
`void readBinaryTree(BinaryTree **p, ifstream *fin) {`
`readBinaryTree(&p, fin)`
???
Thanks
C has no references, so you'd use a pointer to a pointer. The concept of using a pointer to an object to modify the object can be applied recursively, and the "object" you need to modify can be a pointer.
Can someone tell me how to write
You already answered your own question.
I think you have answered your own question very well ;) any more doubts if you have, that are welcomed. thanks if i am helpful to you. :-)
Will @samohitvii Will you elaborate more what exactly you were trying to do ? From this post of yours, I am unable to intrepret what exactly you trying to ask as you have answered your own question.
@waltP it's not i am here to increase my posts up. I will not get dollars for that. I am just giving my view in this. I am just adding something here which is my opinion. If you think it is NOT acceptable, then it's okay! thanks if i was helpful in this thread.
http://www.daniweb.com/software-development/c/threads/433089/hint-in-a-question#post1858665 what have you added in your first post in this thread. this will give your answer which you asked me in the comment of last post. thanks i am clear in my post. :-)
C has no references
C does not have ifstream either. Perhaps the desired conversion is to a FILE*
? One should not assume that though. The OP needs to clarify the goal.
I don't really understand why people think I answered my own question. An answer I am looking for is something along the lines of
C++
void readBinaryTree(BinaryTree* &p, ifstream *fin)
C
void readBinaryTree(BinaryTree* *p, FILE* fin)
prototype:
void readBinaryTree(BinaryTree**, FILE*)
and then used in the program
int main()
{
//Open filestream and create a bianry tree
readBinaryTree(&myTree, fin);
}
That's my guess at how you would do it in C but can someone clarify this. I don't really think I need to post the rest of the program.
Thanks
An answer I am looking for is something along the lines
Because that's exactly how its done.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.