Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-18-2003, 02:17 PM   #1 (permalink)
TheDreamless
Registered User
 
TheDreamless's Avatar
 
Join Date: Apr 2003
Posts: 10
TheDreamless is on a distinguished road
Send a message via AIM to TheDreamless
array of characters in a structure

Code:
TreeNode *treesearch(TreeNode *root, char target[21])
{
TreeNode *newnode = NULL;
if(root)
        {
        if (strcmp(target, root->word) < 0)
                {
                if (root->left == NULL)
                        {
                        newnode = (TreeNode *)malloc(sizeof(TreeNode));
                        newnode->count = 1;
/*PROBLEM OCCURS BELOW*/  
                        newnode->word = target;
                        newnode->left = NULL;
                        newnode->right = NULL;
                        root->left = newnode;
                        }
                else
                        root = treesearch(root->left, target);
target is a char array and word is a char array yet GCC wont let me do it. Do i have to use strcpy? Or am i such a n00b (dont answer that just help me!)?
TheDreamless is offline   Reply With Quote
Old 04-18-2003, 03:08 PM   #2 (permalink)
alpha
Regular Contributor
 
Join Date: Feb 2003
Posts: 120
alpha is on a distinguished road
Send a message via AIM to alpha
Code:
int i;

for(i = 0; i < sizeof(target); i++) {
  newnode->word[i] = target[i];
}
or i think you may be able to use strcpy.
alpha is offline   Reply With Quote
Old 04-18-2003, 03:19 PM   #3 (permalink)
TheDreamless
Registered User
 
TheDreamless's Avatar
 
Join Date: Apr 2003
Posts: 10
TheDreamless is on a distinguished road
Send a message via AIM to TheDreamless
Thanks for the reply strcpy fixed all my errors. I thought it might. If only now I could figure out how to make a recursive fcn to find a binary tree's height =). Workin on it =P
TheDreamless is offline   Reply With Quote
Old 04-18-2003, 04:30 PM   #4 (permalink)
alpha
Regular Contributor
 
Join Date: Feb 2003
Posts: 120
alpha is on a distinguished road
Send a message via AIM to alpha
post up if you need help.
alpha is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
working with Array Goong MS Technologies ( ASP, VB, C#, .NET ) 3 07-22-2004 12:14 PM
breaking down an array from a form metazai PHP 12 07-09-2004 06:18 AM
structure problem Goshi Standard C, C++ 5 04-21-2003 12:19 AM
array max num Apodysophilia Java 9 04-10-2003 06:36 AM
adding to an array in php sde PHP 1 06-12-2002 11:04 AM


All times are GMT -8. The time now is 04:20 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting