C Programming Question

Glavinsolo

Platinum Member
Sep 2, 2004
2,946
0
0
Basically the code is done and is finished. There is one last touch that needs to be done. The token words that are captured from the strings need to be trimmed down by removing the 's' 'ed' or 'ing' suffixes. Please help me with the code that will do this removal.

Thanks

-Glavin

What this code does.... Takes in a text file and returns the words/tokens and also the number of times they occur.

 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
First off you need to indent your code properly. I can't really make much sense of it without proper indentation and I'm too lazy to paste it somewhere and correct it just to look at your code.
 

Glavinsolo

Platinum Member
Sep 2, 2004
2,946
0
0
How about this

I was thinking about copying the pointer tok into the character array convert. and then looking for ing ed and s at the end. Taking the string length convert and then wacking the last 3 last 2 or last 1 out of the array and then copying back the array into the pointer.

But I don't think that would work.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126

get the length,
if over 3, check for ending ing by compare like strcmp(&string[len-3], "ing")
if match, set that index of the string to 0 to terminate the string

depending on the number of possible combinations, like "s" AND "ing", a do.... while(trimmed_something) loop might be the clearest approach.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
You mean \0?

And your indentation is better but still pretty awful. Maybe you should use a better editor, with auto indentation? If you want to program you have to pay a lot of attention to seemingly stupid little things. In the end, proper indentation makes things MUCH easier to understand.
 

Glavinsolo

Platinum Member
Sep 2, 2004
2,946
0
0
ha, I am programming on a sun microsystems box nothing but pico for me

Also I got it and it runs perfect. Thanks daveSimmons for clearing the mental block. I forgot about the & with pointers. BingBongWongFooey my teacher will be happier now when grading.

Thanks again