-1

I received a homework in a University to write a C program for finding rhymes. Basically, user should input one stanza/strophe within 4 lines.

If 1st and 3rd line end up with words which have same last three letters, they are recognized by the program as rhyme.

There are also some other things, like if 2nd and 4th end up on the same way.

But, I am just confused - how should I accomplish this? which library should I include in my program so I could achieve this?

Eugene Sh.
  • 17,802
  • 8
  • 40
  • 61
  • 2
    This can all be done with standard C. No extra libraries needed. All you need to know is how to read strings from standard input, about how you can have an array of arrays, and know about strings and indexes and `strlen`. Think about what character e.g. `strlen(X) - 1` would be if used as an index into the string `X`. – Some programmer dude Nov 14 '17 at 19:44
  • 1
    The `librhymes` should do.. – Eugene Sh. Nov 14 '17 at 19:45
  • Build the program step by tiny step. Step 1 the `"Hello, World!"` program. Step 2 input one string and print it. And so it goes. Without the [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) that shows what you have tried, nobody knows where you are. – Weather Vane Nov 14 '17 at 19:49
  • It's hard to help you when we don't know specifically what you're stuck on. Have you worked out an algorithm yet? If so, share it with us and ask us about what specifically you're stuck on with implementing it. If not, ask us about what you're specifically having trouble working out an algorithm for. "How do I build a bridge" is just not an answerable question beyond "learn about bridge building". – David Schwartz Nov 14 '17 at 19:51
  • It's exactly as said in the first comment, you don't need any special libraries, and if you follow the hints in it you'll get it done. Start with reading the input into array of arrays or array of pointers. And if you get stuck, post an MCV on SO. This is not a difficult assignment, if you don't get it well, next one will be a sad experience. Is this ETF? – atru Nov 14 '17 at 20:06
  • SO is not a code writing service... If you're stuck on some specific thing then we'd gladly help if you pointed out the problem and maybe (not always necessary) provide a [mcve]. If you're unsure of where to start then you should seek guidance from your tutor, or grab a [good book on C](https://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list). – George Nov 14 '17 at 20:15
  • OK, i have found it out how to do it! Basically, i need to have 4 char arrays, to include string.h library and then i will use strcmp function to compare only the last 3 letters of the array/line. Thanx for the help guys :) – Dusan Sladojevic Nov 14 '17 at 20:39
  • @atru - no it's not ETF it's RAF :) – Dusan Sladojevic Nov 14 '17 at 20:41
  • Ah :) Looks nice, I don't think it was there during my time :) Good luck :) – atru Nov 14 '17 at 20:53

1 Answers1

1

OK, i have found it out how to do it! Basically, i need to have 4 char arrays, to include string.h library and then i will use strcmp function to compare only the last 3 letters of the array/line. Thanx for the help guys :) –

  • 1
    Look into having a single array with pointers to each of the 4. Provided that you already covered that. If not, then separate arrays will do. – atru Nov 14 '17 at 20:55