Advertisement
KaeruCT

main.c

Jan 26th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "str.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.     printf("--strchr--\n");
  7.     char *str = "this is a test!";
  8.     printf("%s\n", my_strchr(str, 'a'));
  9.    
  10.     printf("\n--substr--\n");
  11.     char *substr = my_substr(str, 0, 9);
  12.     printf("%s\n", substr);
  13.     free(substr);
  14.    
  15.     printf("\n--strstr--\n");
  16.     printf("%s\n", my_strstr(str, "test"));
  17.     printf("%s\n", my_strstr(str, "this"));
  18.    
  19.     char *notfound = my_strstr(str, "unexistent");
  20.    
  21.     if(notfound != NULL){
  22.         printf("%s\n", notfound);
  23.     }
  24.    
  25.     printf("\n--strsplit--\n");
  26.     size_t max_len = 32;
  27.     char *splitted[max_len];
  28.     size_t len = my_strsplit(str, ' ', max_len, splitted);
  29.     int i;
  30.    
  31.     for(i = 0; i < len; i++)
  32.     {
  33.         printf("%s\n", splitted[i]);
  34.         free(splitted[i]);
  35.     }
  36.    
  37.    
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement