Advertisement
Guest User

Untitled

a guest
May 24th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. void myreadline(char x[200]){
  4. fgets(x,200,stdin);
  5. }
  6.  
  7. int mystrlen( char x[40] ) {
  8. int i;
  9. for( i = 0; x[i] != '\0'; i++ );
  10. return i-1;
  11. }
  12.  
  13. int mystrcpy( char a[], char b[] ) {
  14. int i =0;
  15. do{
  16. b[i]=a[i];
  17. i++;
  18.  
  19. } while(a[i-1]!='\0');
  20. return i-2;
  21. }
  22.  
  23. int mystrcmp( char a[], char b[]){
  24. int i,j;
  25. for(i=0; a[i]!='\0';i++){
  26. for(j=0;b[i]!='\0';j++){
  27. { if(a[i]==b[j])
  28. return 1;
  29. }
  30. if(a[i]!=b[j])
  31. return 0;
  32. }
  33. }
  34. }
  35.  
  36. int mysubstring(char glavni[], char sporedni[]){
  37. int i,j;
  38. for(i=0;glavni[i]!='\0';i++){
  39. for(j=0;sporedni[j]!='\0';j++)
  40.  
  41. {
  42. if(glavni[i+j]!=sporedni[j])
  43. break;
  44. if(j==mystrlen(sporedni)-1)
  45. return i;
  46. }
  47. }
  48. return (-1);
  49. }
  50.  
  51. void mytoupper(char str[])
  52. { int i;
  53. for(i=0;str[i]!='\0';i++){
  54. if((str[i]>=97)&&(str[i]<=122))
  55. str[i]=str[i]-32;
  56. }
  57. }
  58. void mytolower(char str[])
  59. { int i;
  60. for(i=0;str[i]!='\0';i++){
  61. if((str[i]>=65)&&(str[i]<=90))
  62. str[i]=str[i]+32;
  63. }
  64.  
  65. }
  66.  
  67. void myinvertcase(char str[]){
  68. int i;
  69. for(i=0;str[i]!='\0';i++){
  70. if((str[i]>=97)&&(str[i]<=122))
  71. str[i]=str[i]-32;
  72. else if((str[i]>=65)&&(str[i]<=90))
  73. str[i]=str[i]+32;
  74. }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement