-
right i've done that now and it has solved the problem, which gives me another one.
The pointer stored in root->next is the memory address of the next word which I know is correct, although it seems to think the pointer is null. why would this happen?
Edit: it seems it does test the words but then doesn't seem to call the function again, what I want it to do is test whether or not the word entered by the user is in the list and how many times it occurs.
Edit: Edit: it searches through the list now but seems to get a pointer error on the last node I think.
-
duh of course I get a pointer error as it is the start of the list, anyway it now seems to work although b should be the number of times a word occurs in the list and it doesn't always seem to be.
Also is it possible to return both a and b from the same function?
-
you can pass them by pointer
-
thanks, I realised I only needed to transfer them back to print out so I have just incorporated the printf statements into the search function.
Just wondering is it possible to condense the printf commands below anymore:
Code:
printf("\n'%s'", word);
printf(" occurs ");
printf("%d", b);
printf(" times.\nRetrieval from list took");
printf("%d",a);
printf(" comparisons. ");
-
printf("\n'%s' occurs %d times.\nRetrieval from list took %d comparisons.", word,b,a);
-
I want to remove apostrophes from my text, but if I use the following statement it thinks there are too many as they are the initialiser for the query. How would I get round this? I was wondering whether it is possible to use ASCII code.
x[b] == '''
thanks
-
you can use \" to print quote instead of the '
-
so i should use
x[b] == '\"'
because it doesn't seem to work.
-
i mean you can write
Code:
printf("\n\"%s\" occurs %d times.\nRetrieval from list took %d comparisons.", word,b,a);
if you want to do something else - please explain a little bit more
-
no sorry I am trying to remove all the apostrophes from my list so when it is searched they don't appear in words.
so I was trying to compare each character in the list with an apostrophe to allow me to find and remove them.
my attempt was x[b] == '''
with the highlighted bit being the condition.
-
You'd need an escape char with that. . . '\'' where the \ means the next char, if not a special char is litteral.
-
thanks, thats great it works now