Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. //Kevin Chettri
  2. #include <stdio.h>
  3. #include<string.h>
  4. #include<stdlib.h>
  5. #include<ctype.h>
  6.  
  7. #define LETTERS 26
  8.  
  9. int initialize(char *string1, char *string2);
  10. void getString(char *firststring, char *secondstring);
  11. int setLetters(char *string1, char *string2);
  12.  
  13. void main(void)
  14. {
  15. int i = 0;
  16. char *string1[LETTERS];
  17. char *string2[LETTERS];
  18.  
  19. while (i != 1) {
  20. initialize(string1, string2);
  21. getString(string1, string2);
  22.  
  23. setLetters(string1, string2);
  24.  
  25. printf("\n\nFirst string: %s\nSecond String: %s\n\n", string1, string2);
  26.  
  27.  
  28. }
  29.  
  30. }
  31.  
  32. int initialize(char *string1, char *string2) {
  33.  
  34. int i=0;
  35.  
  36. for (i=0; i <= LETTERS; i++) {
  37. string1[i] = 0;
  38. string2[i] = 0;
  39. }
  40.  
  41. }
  42. void getString(char *firststring, char *secondstring) {
  43.  
  44. printf("Enter a line: ");
  45. gets(firststring); // save room for ‘\0’
  46.  
  47. printf("Enter a line: ");
  48. gets(secondstring); // save room for ‘\0’
  49.  
  50. }
  51. int setLetters(char *string1, char *string2) {
  52.  
  53. int i, m, k, a, b;
  54. char chr[LETTERS] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  55. char newstring1[LETTERS], newstring2[LETTERS];
  56.  
  57. for (k=0; k <= LETTERS; k++)
  58. newstring1[k] = 0;
  59. newstring2[k] = 0;
  60.  
  61. for (i=0; i < strlen(string1); i++) {
  62. for (m = 0; m <= LETTERS; m++) {
  63. if (string1[i] == chr[m]) /* <-- ASCII NUMBER */
  64. newstring1[m]++;
  65. }
  66. }
  67.  
  68. for (a=0; a < strlen(string2); a++) {
  69. for (b = 0; b <= LETTERS; b++) {
  70. if (string2[a] == chr[b]) /* <-- ASCII NUMBER */
  71. newstring2[b]++;
  72. }
  73. }
  74.  
  75.  
  76. }
  77.  
  78.  
  79.  
  80.  
  81. /* checkLetters() {
  82.  
  83. // string1[i] - string2[i] = string3[i]
  84.  
  85.  
  86.  
  87. }
  88.  
  89. isZero() {
  90.  
  91. // if string3[i] == 0 always, printf anagram, else don't.
  92.  
  93. }
  94. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement