Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *Teste (char *s1, const char *s2) {
- char *aux=s1, *aux_=s2;
- int i, aux1=0, aux2=0, aux3=0;
- //(a)
- for (i=0; s1[i] != '\0'; i++)
- {
- if (s2[i] == '\0')
- break;
- if (s1[i+1] == '\0' && s2[i+1] != '\0')
- {
- *(aux_+i+1) = '\0';
- break;
- }
- *(aux_+i) = s1[i];
- }
- //(b)
- while (*s1 != '\0')
- s1++;
- if (s1 < s2)
- {
- while(s1 != s2)
- {
- *s1 = '\0';
- s1++;
- }
- }
- s1 = aux;
- //(c)
- for (i=0; s2[i] != '\0'; i++)
- {
- aux1=aux1+(int)s1[i];
- aux2=aux2+(int)s2[i];
- }
- if (aux1 == aux2)
- aux3 = 0;
- if (aux1 > aux2)
- aux3 = 1;
- if (aux1 < aux2)
- aux3 = -1;
- //(d)
- for (i=0; s2[i] != '\0'; i++)
- {
- if (s1[i] == '\0')
- break;
- if (s2[i+1] == '\0' && s1[i+1] != '\0')
- {
- s1=realloc(s1,(i+1)*sizeof(char));
- s1[i+1] = '\0';
- break;
- }
- s1[i] = s2[i];
- }
- //(e)
- while (*s1 != '\0')
- s1++;
- s1++;
- for (i=0; s2[i] != '\0'; i++)
- {
- *s1 = s2[i];
- s1++;
- }
- return aux;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement