DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C (http://www.daniweb.com/forums/forum118.html)
-   -   @@ ListFuns.c @@ (http://www.daniweb.com/forums/thread40989.html)

minorityreport Mar 12th, 2006 7:40 pm
@@ 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 <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(!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;
}

Narue Mar 12th, 2006 8:07 pm
Re: @@ ListFuns.c @@
 
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.

minorityreport Mar 12th, 2006 8:11 pm
Re: @@ ListFuns.c @@
 
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

Rashakil Fol Mar 13th, 2006 2:58 am
Re: @@ ListFuns.c @@
 
Um, why would you even expect this code to work? Do equalsList, precedesList, and stringToList work as advertised?

Narue Mar 13th, 2006 9:44 am
Re: @@ ListFuns.c @@
 
>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.

minorityreport Mar 13th, 2006 9:44 am
Re: @@ ListFuns.c @@
 
hi, i have got the programme working;
thanks

Narue Mar 13th, 2006 9:51 am
Re: @@ ListFuns.c @@
 
>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.


All times are GMT -4. The time now is 7:24 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC