Salem's suggestion did the trick. Thanks everyone.
Type: Posts; User: lime
Salem's suggestion did the trick. Thanks everyone.
Ignore the "int receiver" in the struct code. I just copied it from my actual program. It doesn't really have anything to do with this example program (which I can't seem to get working anyway).
#include <stdio.h>
#include <string.h>
struct person
{
char name[20];
int receiver;
};
If I had an array of structures (like a database say) and I entered in 5 people. How could I make a program that prints out a file for each of the people without actually coding the filename into...
I hear you can program CGI scripts with C or C++. Does anyone know how this is done?
Also, I read that if you use the unix or linux, you can compile a cgi file out of C or C++. How do you do...
Ok I understand now. Thanks. But how would you go about overloading an operator? Would it be possible for you to give me a short example? Or a link to a good explanation/example?
Hello. I'm new to C++ but I have some knowledge of C. You may laugh because I don't know what overloading means. I've been doing some reading and I have the vauge idea that overloading means you...
is the (int) necessary in front of the log(n)?
Just curious because it would make printing out an matrix much easier.
Thanks.
ok i have some code here that tells me how to find the depth
int depth(NODE *node)
{
int left = -1; // clear left
int right = -1; // and right
...
wow, that's a pretty compact little recursive function :)
Would I be able to modify that code so it could count levels as well as the number of elements per level?
Uh hi, it's me again. I have another question.
It's another one about binary search trees.
I made one that works. I can tell that it works by traversing it in order. I've seen a lot of...
would NELEM(x) also work for arrays of pointers?
Here's a simple question that I don't know the answer to. I hope someone knows a trick or two.
Say you have two arrays and you want to make a single function to print the out the elements. One...
AHA I figured it out. I have to add an else statement to decrement i (in the for loop in the randomWords function) if a repeated word has been found. (because the for loop would stop at 100 anyways...
Ok i do have it working but not properly. This time, it's giving me 192 random words when it should be giving me 100. I also noticed that when I traverse the tree and print the words out, I only...
ooohh silly me. Ok I got it working thanks hammer.
oh I see, so I would have to type
NODE *somenode;
somenode=insert(root, words[randnum].word);
something like that?
In that case I suppose I should just post it all. Thanks for helping me with this problem by the way.
#include <stdio.h>
#include <stdlib.h>
#include <string.h> /*to use strcpy*/
#include...
Thanks lightatdawn. I changed that to '=='.
And thanks Salem. I used your suggestion and took out createtree and used your code for NODE insert(etc...). That seemed to fix the error I was...
I'm writing a program where I have to randomly choose 100 words from an array and put it into a binary search tree. I got the array working the random selection working but putting the words into...
Hey money? the code you suggested actually worked (yay, thanks) but only for the first word I scanned in. so for example in the second list my first word was "house" and then it went through the...
Were you looking for something like this?
sqrt(x)?
It returns the squareroot of x.
.
It's included in math.h
This is how i defined the linked list:
/*structure of linked list*/
struct node{
char data[9];
struct node *next;
};
typedef struct node NODE;
Hi folks, I have another little problem.
I've been working on a program that's supposed to compare two text files (of lists of words) and see if they have all the same words (regardless of what...