Thread: Girl ** C needs help

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    15

    Girl ** C needs help

    Hey guys, can you help me again please?
    I've been working on this for two weeks and it's due in on Friday.
    I've tried to compile this code but am using gcc in wondows and its
    not working properly on my laptop.

    Im just finishing the hardest parts
    wordADT.c
    BStreeADT.c and
    the main c page(wordCount where I do testing)
    This is my code for wordADT, it is a linked list and the type
    definition for this ADT is.....

    Code:
    struct wordCDT
    {
        char data;
        wordADT next;
    };
    these are the functions, all of which must be coded
    recursively(except buildWord)

    Code:
    #include <stdio.h>
    #include "boole.h"
    #include "wordADT.h"
    #include "listADT.h"
    
    
    /*---------------------------------------Functions----------------------------------------*/
    
    wordADT createWord()
    /*desc: returns a new, empty list*/
    {
        return NULL; /*empty list is pointer to NULL*/
    }
    
    
    wordADT reverseWord(wordADT word)
    /*desc: returns a word with the chars in reverse order*/
    {
        wordADT rWord=createWord();                             /*create temp list*/
     /* rWord=malloc(sizeof(wordADT))    */                       /*allocate storage space?????do I need this line?*/
        while (!isEmptyList(word))                              /*while list is not empty*/
        {  
            rWord=consList(headList(word),rWord);               /*tempList is constructed with head of word at the
                                                                                     end of templist(i hope)*/
            reverseWord(tailList(word));                            /*move to next node?????*/
        }
        return rWord;
    }
    
    
    wordADT buildWord(char str[])  
    /*desc: converts a C string (array of char) into the
            corresponding word (list of characters)*/
    {
        wordADT newWord=createWord();                           /*create empty word*/                                  
        int count=1;                                            /*declare integer count*/
        while (str[count]!='\0')                                /*stopping condition-while string not empty*/
        {
            newWord=consList(str[count],newWord);               /*word is constructed by adding string item to wordADT*/
            count++;                                            /*increment count so it is closer to stopping condition*/
        }
        return reverseWord(newWord);                           /*recursion will cause string to be entered into wordADT
                                                                      backwards so I return reverse of this word*/
    }
    
    void displayWord(wordADT word) 
    /*desc: displays a word*/ 
    {
        while(!isEmptyList(word))                               /*Stopping condition-is this the right stopping condition??*/
        {
           printf("%c",headList(word));
           displayWord(tailList(word));     
        }
    
    }
    
    
    int countChars(wordADT word) 
    /*desc: counts the number of characters in a word*/
    {
        if(isEmptyList(word)==TRUE)
        {
            return 0;                                  /*basically a length function, but would I */
        }                                              /*be better using headList/tailList????????*/
        else 
        {
            return(1+countChars(tailList(word)));
        }
    }
    
    
    boolean wordLess(wordADT word1, wordADT word2) 
    /*desc: returns TRUE if the word in word1 is alphabetically
            before that in word2*/
    {
        if (isEmptyList(word2)==FALSE)
        {
            if(headList(word1)<headList(word2))
            {
                return TRUE;
            }
            else if (headList(word1)==headList(word2))
            {
                return wordLess(tailList(word1),tailList(word2));
            }
        }
        else
        {
            return FALSE;             /*do I need error messages*/
        }
    }
    
    
    boolean wordEqual(wordADT word1, wordADT word2) 
    /*desc: returns TRUE if the word in word1 is equal to that
            in word2*/
    {
        if (isEmptyList(word1)||isEmptyList(word2))               
        {
            return TRUE;
        }
        else if (isEmptyList(word1)||isEmptyList(word2))
        {
            return FALSE;
        }
        else if (isEmptyList(word1)||isEmptyList(word2))
        {
            if(headList(word1)==headList(word2))
            {
                return wordLess(tailList(word1),tailList(word2));
            }
            else
            {
                return FALSE;
            }
        }
    }
    
    /* OR SHOULD I USE this function which seems more elegant!
    if (wordLess(word1, word2)==TRUE)||(wordLess(word2, word1)==TRUE)
    {
        return TRUE;
    }
    else 
    {
        return FALSE; 
    }
    */
    I've already had help with wordLess and wordEqual, do you think they
    should be implemented with nested if's????
    Eek any help on where you think I could be going wrong would be greatly
    appreciated!!!!

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So what's your problem? No one here is simply going to read everything because you say you're a girl. Frankly, no one cares. I'd suggest you learn to ask good questions. Also, try actually posting errors you get, or at least saying if it does in fact compile. Does any of it work? What part? What does it do wrong?

    See? You just throwing up a bunch of code doesn't help anyone even remotely want to help you. How about being helpful if you want help?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    15
    You horrible little man. Like I've said before if you are going to be mean just because you know C don't reply to me.
    I said I've had a good stab at this and my compiler is'nt working because it's having problems with linking. Im asking people to have a look and see if i've messed up. If you don't want to help don't...go pick on someone as pretentious as yourself and I'm not trying to get help cos I'm a girl you don't know me don't judge me.
    Theres nothing wrong with my question just your attitude.

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    While his attitude may be a bit aggressive, his statement is true. If you have any trouble with this piece of code, please post an exact error description along with it. Do you get compiler errors ? Linker errors ? Does it produce strange results ? What errors are you getting, what result is produced and what is required ?

    You aready experience problems. People are lazy and while we are happy to give an answer, we don't want to go looking for questions first.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The fact is, I can and will judge you. You made a post here asking for help. Your post provided nothing at all useful for us to determine what your problem is. Yet you expect help. Why? You've done nothing at all to warrant it. You don't even try to explain what is wrong. You simply regurgitate some code and say "help me".

    Yeah, that's really useful. "Here's some code, you guys compile it and find out what's wrong with it, and then post the corrections for me." Sorry, it just doesn't work that way. And yes, you specificly mentioned you were female because you thought it would help your case or improve the response your post would get. Why on earth would it be in the post title otherwise?


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    Feb 2005
    Posts
    15
    I'm not being lazy. It compiles fine but it wont run on my computer.
    I'm just asking that someone who has the time and is'nt going to be rude have a look at it and give me hints if they can see a function where i have missed a case out....for example if a function will fail on an empty case. I've also asked which is the best way to implement the final function because in terms of c 'ettiquette' i'm not sure which is more elegant.
    If people don't want to look at my code why reply to me, why not just leave it until somebody who does comes along.
    I'd help somebody if I was actually good at C and not give them a hard time.

  7. #7
    Registered User
    Join Date
    Feb 2005
    Posts
    15
    Cos i would hope somebody would take pity on me cos I'm useless.
    Hardly like ive thrown some code on and said help me.
    Go pick on someone else and stop replying on my post if you arent gonna help.

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    How exactly does it "not run"? See still you aren't even providing anything useful. Also, why did you make a new thread for the same topic? Fine, you want help? Here it is:

    Test each of your functions one at a time in a seperate program. Make them each work seperately. Then combine them into your main program.

    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Registered User
    Join Date
    Feb 2005
    Posts
    15
    Well see now you aren't listening.
    It compiles but when I try to run it i'm gettin and error message I dont understand, hovever i think is gcc runnin in windows having problems linking all the header files.

    Not asking to post me perfect code for my functions, just one or two hints if you can see anything i'm tripping up on, like I've used crappy recursion or not the right base case.

    Also I've read the FAQ's and posting announcements but if I make mistakes on the forum it's probably because I havent posted 5,000 times and I'm a little rusty
    Last edited by sam.woolner; 03-02-2005 at 03:45 AM.

  10. #10
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    I dont understand the message hovever
    Well there is a good chance that we would understand the message. The problem is that you seem reluctant to actually post what the message is, and that makes it impossible for us to help you.

  11. #11
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by sam.woolner
    Well see now you aren't listening.
    It compiles but when I try to run it it fails
    Ok, this discussion has gone far enough. I'll end with this:

    What exactly is "when I try to run it fails"? That means absolutely nothing. Does it display any output at all? Does it generate a segfault? Does it prompt for input, but give the wrong output? See? Try taking a few seconds to actually think about what you post. Because as I've stated multiple times now, "doesn't run" means NOTHING to us.

    I did give you a hint. As a matter of fact, I gave you the one sure fire way to fix your own problem. That is, to test each function one at a time. That's THE BEST way to fix your own code. It's called debugging. When something doesn't work right, you test it in small test cases until you know for a fact that "A doesn't work, but B does, so B is not the problem".

    But wait! It gets even better!
    Quote Originally Posted by sam.woolner
    I dont understand the message hovever i think is gcc runnin in wondows having problems likeing all the header files.
    Oh, so now, after we've already asked for you to post any messages you get, you say it gives you some message you don't understand.

    Really? That's funny, I don't see it posted here. I mean, we DID ASK FOR IT ALREADY. Where is it? It's not here. Maybe it's a secret message. Well whatever it is, YOU STILL DIDN'T POST IT like you were asked on more than one occasion.

    But somehow I wasn't listening. Yeah, that must be it.


    Quzah.
    Hope is the first step on the road to disappointment.

  12. #12
    Registered User
    Join Date
    Feb 2005
    Posts
    15
    It just that it was on my laptop and i can't remember it...it says error: then it shows the directory path of gcc, i know thats a really silly description but I think i'ts having problems using the header files i've included.
    I downloaded visual basic C/C++ compiler but dont know how to use it lol. As far as the code goes though it compiles, there aren't any parse errors. It's more my methods i'm worried about.
    For example in reverseWord i've got a feeling it just returns the list in the same order.
    Plus I don't know If i need to use that malloc line.

  13. #13
    Registered User
    Join Date
    Feb 2005
    Posts
    15
    Thanks for taking so much time to tell me off, quotes and everything, try and realise for a second I'm not confident with programming.
    You can't do that and that's why characters like the computer geek in the office are written.

  14. #14
    Registered User computerfreaks's Avatar
    Join Date
    Jan 2005
    Posts
    30
    The best thing that I find to do...

    If your code compiles, but still doesn't run fully, then there is usually some kind of memory error. You need to locate the exact point at which your code fails.

    To do this, ask you program to print a line of text that you can easily locate..... e.g.

    Code:
    printf("Debug 1\n");
    system("pause");
    Now do this at different points in the program (obviously changing the number in the debug line!). Now run it again.

    This way you will know exactly how far your program is getting, allowing you to rule out loads of functions etc. When you have found this out, you can try to fix it. If you still can't fix it, then at least you can post here and know exactly where about it fails.

  15. #15
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    Doesn't really look like this is getting solved. I can sort of see all points here. Sam, compile your code again on the machine it failed on last time and post back the exact error and all the info that the compiler prints out.

    If you think the problem lies with the header files, it is most likely to be with your own files. Check through them and if you think the problem is with linking your own headers then try moving them to the header directory for your compiler and using
    #include <myheader.h. instead of quotes.


    ps: if you are compiling on the command line then include the flags you are using -o -ansi etc..
    hth
    Monday - what a way to spend a seventh of your life

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Give the Jew Girl Toys
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 12-23-2005, 02:44 PM
  2. What signs are there of that a girl is in love with you?
    By A_guy in forum A Brief History of Cprogramming.com
    Replies: 29
    Last Post: 05-21-2003, 07:48 AM
  3. Girl Scout Cookies
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 02-14-2003, 06:02 AM
  4. Guy or Girl
    By golfinguy4 in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 03-14-2002, 05:00 AM