code from my str_whereis.c
Code:
int str_whereis_string(char *src, char search[]) {
char *location = strstr(src, search);
if(location == NULL)
return -1;
return (strlen(src) - strlen(location));
}
basicly everything in my str_cat.c(need for my tag code i posted before)
Code:
int str_catbefore(char *src, char string[]) {
char *newstring = malloc( strlen(src) + strlen(string) + 1 );
strcpy(newstring, string);
strcat(newstring, src);
strcpy(src, newstring);
free(newstring);
return 0;
}
int str_catafter(char *src, char string[]) {
char *newstring = malloc( strlen(src) + strlen(string) + 1 );
strcpy(newstring, src);
strcat(newstring, string);
strcpy(src, newstring);
free(newstring);
return 0;
}
int str_catboth(char *src, char before[], char after[]) {
str_catbefore(src, before);
str_catafter(src, after);
return 0;
}
my tml_createstarttag function code.
Code:
int html_createstarttag(char *dest, char tag[]) {
char *string = malloc( strlen(tag) + 3 );
strcpy(string,tag);
catboth(dest, "<", ">");
strcpy(dest, string);
free(string);
return 0;
}
i attempted to make it more all purpose. im not thrilled about all my includes, but i like this style better(keep in mind im the n00b here). what do you guys think?