Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. char * select(char * str);
  5.  
  6. int main(){
  7. char entered[255] = "";
  8. char * selected = NULL;
  9.  
  10. printf("Enter ur string: ");
  11. fflush(stdin);
  12. scanf("%254[^\n]s",entered);
  13.  
  14. selected = select(entered);
  15. printf("%s", selected);
  16.  
  17. return 0;
  18. }
  19.  
  20. char * select(char * str){
  21. char * temp = NULL;
  22. int i=0,j=0;
  23.  
  24. while(*(str+i) != '\0'){
  25. if(*(str+i)>='A' && *(str+i)<='Z'){
  26. if(i==0 || *(str+(i-1))==' ' || *(str+(i-1))=='\t'){
  27. while(1){
  28. temp = (char *)realloc(temp, (j+1)*sizeof(char));
  29. *(temp+j) = *(str+i);
  30. i++;
  31. j++;
  32.  
  33. if(*(str+i)==' ' || *(str+i)=='\0' || *(str+i)=='\t')
  34. break;
  35. }
  36. }
  37. }
  38. else
  39. i++;
  40. }
  41. *(temp+j) = '\0';
  42. return temp;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement