Advertisement
Guest User

Untitled

a guest
May 27th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1.  
  2. char *devide(char *str, char ch)
  3. {
  4. char *strpos = str;
  5. char* newStr;
  6. while (*strpos != '\0' && *strpos != ch) {
  7. ++strpos;
  8. }
  9.  
  10. if (*strpos == '\0')
  11. printf("%c was not found in string", ch);
  12.  
  13. newStr = (char*)malloc((strlen(strpos) + 1) * sizeof(char));
  14.  
  15. if (!newStr)
  16. return NULL;
  17.  
  18. strcpy(newStr, strpos);
  19.  
  20. return newStr;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement