Advertisement
Guest User

Untitled

a guest
Oct 16th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdlib.h>
  3.  
  4. void functionI(*char);
  5. void functionD(*char);
  6. void functionL(*char);
  7. void functionR(*char);
  8.  
  9. int main(int argc, char *argv[]){
  10.  
  11. char functioncall[10];
  12. char word[101];
  13. FILE *fp = fopen(argv[1], "r");
  14. fscanf(fp, "%s", word);
  15. fscanf(argv[2], "%s", functioncall);
  16.  
  17. if(argc != 3){
  18. printf("Error");
  19. return 1;
  20. }
  21. while( ! feof(fp) ){
  22. int i;
  23. for(i=0; i<strlen(argv[2]); i++){
  24. if(functioncall == 'I')
  25. functionI(word);
  26. else if(functioncall == 'D')
  27. functionD(word);
  28. else if(functioncall == 'L')
  29. functionL(word);
  30. else if(functioncall == 'R')
  31. functionR(word);
  32. }
  33. sscanf(fp, "%s", word);
  34. }
  35. return 0;
  36. }
  37.  
  38. void functionI(char *word){
  39.  
  40. int i;
  41. for(i=0; i<strlen(word); i++)
  42. printf("%c", word[i]+1);
  43. printf("\n");
  44.  
  45.  
  46. return;
  47. }
  48. void functionD(char *word){
  49.  
  50. int i;
  51. for(i=0; i<strlen(word); i++)
  52. printf("%c", word[i]-1);
  53. printf("\n");
  54.  
  55. return;
  56. }
  57.  
  58. void functionL(char *word){
  59.  
  60. int i;
  61. char temp;
  62. temp = strlen(word);
  63. for(i=0; i<strlen(word); i++){
  64. temp = word[i];
  65. word[i] = word[i+1];
  66. temp = word[i+1];
  67. printf("%c", word[i]);
  68. }
  69.  
  70. return;
  71. }
  72.  
  73. void functionR(char *word){
  74.  
  75. int i;
  76. char temp;
  77. temp = strlen(word);
  78.  
  79.  
  80. return;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement