i need make program reads file, , puts of words in "dictionary" how appear , total number of words. example, if file read
hello, name robert! name cool...
the output be
hello 1 2 name 2 2 robert 1 cool 1 total number of words 9.
however, function prints total number of words, , not words themselves. sorry if trivial question, i'm newbie c.
here's code -
your code buggy in add_to_dictionary method.
problem #1: line 80 should changed if(stringcompare == 0)
(you missing =, makes assignment. stringcompare 0 after executing instead of checking if 0. result of assignment value assigned , 0 equivalent of false in c).
problem #2: loop checks against first item in list. need remove else.
problem #3: line 90 , 91 should not in loop. closing brace on line 92 closes loop.
problem #4: in new_entry, should memcpy
or strcpy
value of stringone, instead of assigning it. assigning pointer makes point new address. want current address have same content other string. that, need go through old memory , copy element element new memory. since lot, wrote function (strcpy
or memcpy
mentioned before).
i didn't check rest of code much, no guarantees list exhaustive.
Comments
Post a Comment