davemx_5

Untitled

May 16th, 2013
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. void Dictionary::translate(char out_s[MAX_WORD_LEN], const char s[MAX_WORD_LEN])
  2. {
  3. int i = 0;
  4. for (i=0;i<numEntries;i++)
  5. {
  6. if (strcmp(englishWord[i], s)==0)
  7. break;
  8. }
  9. /* if ( i<numEntries){
  10. strcpy(out_s, elvishWord[i]);*/
  11.  
  12. for(int i = 0; i<numEntries;i++)
  13. {
  14. char *not_found = {'\0'};
  15. if(strcmp(englishWord[i],s)!=0)
  16. {
  17.  
  18. // do{out_s[i] ='\0';i++;}while(i<MAX_WORD_LEN);
  19. int leng = 0;
  20. leng = strlen(s);
  21.  
  22. for( int i = 0; i < leng; i++)
  23. {
  24. strcpy(not_found,s);
  25. not_found[i+1] = not_found[i];
  26. not_found[0] = '*';
  27. not_found[leng-1] = '*';
  28. }
  29. //strcpy(out_s,not_found);
  30. break;
  31. }
  32. // strcpy(out_s,not_found);
  33.  
  34. }
  35. if ( i<numEntries){
  36. strcpy(out_s, elvishWord[i]);
  37. // what do I do if I didn't find the word?
  38. // might want another parameter or return value what
  39. // indicates that the word wasn't found
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment