Can anyone tell me if i have done these functions correctly; i maybe missing something; maybe thats why im getting segmentation fault!!!

#include "listFuns.h"
#include <stdlib.h> 
#include <stdio.h>

listADT stringToList(char str[])
/* desc: converts a C string (array of char) into the */
/* corresponding word (list of characters) */
    listADT temp;
    return temp;

void displayList(listADT list)
{                              // if the list is not empty 
printf("%c", headList(list)); // print the character at the current head of the list 
displayList(tailList(list)); // call the function again with the next character in the list 
printf("\n");          //print a new line 


boolean precedesList(listADT list1, listADT list2)
/* desc: returns TRUE if the word in list1 is alphabetically */
/* before that in list2 */
    return FALSE;
boolean equalsList(listADT list1, listADT list2)
/* desc: returns TRUE if the word in list1 is equal to that */
/* in list2 */
    return FALSE;

You'll get no help by posting partial code and complaining of a vague segmentation fault. If you don't clarify your posts, I'll remove them as spam. Also, for the same problem, keep your posts to a single thread.

hi, i am sorry for being so broad; i am simply debugging and looking for possibilities myself of why i keep getting segmentation fault!

i am new to this forum; thanks for advicing me on the do's and dont's; i looked at the listfuns.c and thought i might be missing something from the instruction.

can you advise me where i may have gone wrong?


Um, why would you even expect this code to work? Do equalsList, precedesList, and stringToList work as advertised?

>can you advise me where i may have gone wrong?
All of the code you've posted consists of either statements that cannot cause a seg fault, or user-defined function calls. The only conclusion is that the fault is in one of those functions, but because you haven't posted the code for any of them, we can't help you. This isn't a difficult concept.

hi, i have got the programme working;

>i have got the programme working
And? I'm quickly beginning to think you're a troll. First you post code that can't be debugged due to lack of information, then you say you've fixed the problem but don't bother to tell us where or what it was.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.