954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

@@ ListFuns.c @@

Hi,

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
#include

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(!isEmptyList(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;
}

minorityreport
Newbie Poster
4 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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?

thanks

minorityreport
Newbie Poster
4 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

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

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 176
 

>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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

hi, i have got the programme working;
thanks

minorityreport
Newbie Poster
4 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

>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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You