Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mystr.c
- 1
- 2 #include <stdio.h>
- 3 #include <stdlib.h>
- 4
- 5
- 6 void myreadline(char a[]){
- 7 gets(a);
- 8 }
- 9
- 10 int mystrlen(char a[]){
- 11 int broj;
- 12 for (int i=0;a[i]!='\0';i++)
- 13 broj=i;
- 14 return broj+1;
- 15 }
- 16
- 17 int mystrcpy(char a[], char d[]){
- 18 int i,k=0;
- 19 for (i=0;a[i]!='\0';i++){
- 20 d[i]=a[i];
- 21 k++;
- 22 }
- 23 d[k]='\0';
- 24 return i;
- 25 }
- 26
- 27 int mystrcmp( char a[],char b[]){
- 28 for (int i=0;a[i]!='\0';i++){
- 29 for (int j=0;b[i]!='\0';j++){
- 30 if(a[i]!=b[j]){
- 31 return 0;
- 32 }
- 33 else if (a[i]==b[j])
- 34 {
- 35 return 1;
- 36 }
- 37 }
- 38 }
- 39 }
- 40
- 41 int mysubstring(char big[], char sub[]){
- 42 for (int i=0; big[i]!='\0';i++){
- 43 for (int j=0;sub[j]!='\0';j++){
- 44 if(big[i+j]!=sub[j])
- 45 {
- 46 break;
- 47 }
- 48 if(j==(mystrlen(sub)-1))
- 49 {
- 50 return i;
- 51 }
- 52 }
- 53 }
- 54 return -1;
- 55 }
- 56
- 57 void mytoupper(char e[]){
- 58 int i;
- 59 for(i=0;e[i]!='\0';i++){
- 60 if (e[i]>96&&e[i]<122){
- 61 e[i]-=32;
- 62 }
- 63 }
- 64 }
- 65
- 66 void mytolower(char f[]){
- 67 int i;
- 68 for(i=0;f[i]!='\0';i++){
- 69 if (f[i]>64&&f[i]<91){
- 70 f[i]+=32;
- 71 }
- 72 }
- 73 }
- 74
- 75 void myinvertcase(char g[]){
- 76 int i;
- 77 for( i=0;i<g[i]!='\0';i++){
- 78 if (g[i]>96&&g[i]<122){
- 79 g[i]-=32;
- 80 }
- 81 else if (g[i]>65&&g[i]<90){
- 82 g[i]+=32;
- 83 }
- 84 }
- 85 }
- 86
- 87
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement