Member Avatar

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

Member Avatar
0
10
Member Avatar

I am looking to create a binary tree and then print it out. I am getting some strange errors I cant fix. #include <stdio.h> #include <string.h> struct animalTree { char data[100]; struct animalTree *left; struct animalTree *right; }; typedef struct animalTree aTree; void fillTree(FILE*, struct animalTree*); int readNext(char*, FILE*, int*); void printTree(struct animalTree*); struct aTree *makeNode(char*); aTree* root; int main() { FILE *fp; fp=fopen("animals", "r"); char stuff[40]; if(fp != NULL) { fillTree(fp, root); printTree(root); } else { root = (aTree*)makeNode("Horse"); } fclose(fp); return 0; } void fillTree(FILE* fp, struct animalTree *node) { char data[100] = {""}; int isNULL = 1; …

Member Avatar
0
5
Member Avatar

I was just wondering if anyone can give me some info on converting C++ to C. I don't really care about finding a program to do it for me, I would just like to know what is different between the two. My program is 'fairly' simple. uses file IO, prints, reads and all the other usual stuff. Does anyone know a decent website that looks at these differences and hows what the ifferences are? What I have worked out. No headers except stdio.h cout = printf fstream = FILE new = malloc Other changes? Thanks

Member Avatar
0
11
Member Avatar

Hi all, Say i have 2 nodes of a tree. struct tree{ int data; tree* left; tree* right; }; NODE1 data = 3; left = NULL; right = NULL and NODE2 data = 6; left = NULL; right = NULL How do i say Node 2 if the left link of node 1 so it creates the start of a tree. So it looks like NODE1 / \ NODE2 NULL I thought I could say node1->left = &node2; // left = the address of node 2. Is that right? Thanks

Member Avatar
0
3
Member Avatar

Hi all, I am having trouble getting a tree to and from a text file. The text file will hold questions and animals. Each node should hold one question and one animal. So if you can imagine: Does it have 4 legs? / \ Does it purr? Does it swim? / \ / \ Cat Dog fish NULL yes being left and no being right. That is the tree that is created. How would that get read into a file. How can I say in the text file "Don't go down any further past 'does it purr', go back to …

Member Avatar
0
16
Member Avatar

Hi all, I have a simple program: #include<iostream> using namespace std; 6 int main() { char x; do { scanf("%c", x); } while (x != 'y'); return 0; } and for some reason when i gcc test.c i get "test.c:1:20: fatal error: iostream: No such fiel or directory compilation terminated." I had a look around but couldn't find oput what the problem is. This is the first time I have used gcc to compile since i installed so could the iostream fiel be missing :S? Please help. Thanks

Member Avatar
0
13
Member Avatar

Hi all, I am trying to write a CWEB c++ program that just keepsgoing until the user types 'no'. Anyway i get some errors that I can't fix. Here is the .w file (x's are comment blocks to save congestion) @* Program Skeleton @ x @c using namespace std;@; @<Header files@>@; @<The main program@>@; @ x @<Header files@>= #include <iostream> #include <fstream> @* x @<The main program@>= int main() { @<Variables of main@>@; do { @<Check play again@>@; } while(continue != "No"); return 0; } @ x @<Check play again@>= cout << "Do you want to play again? "; cin …

Member Avatar
0
3

The End.