Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- char * select(char * str);
- int main(){
- char entered[255] = "";
- char * selected = NULL;
- printf("Enter ur string: ");
- fflush(stdin);
- scanf("%254[^\n]s",entered);
- selected = select(entered);
- printf("%s", selected);
- return 0;
- }
- char * select(char * str){
- char * temp = NULL;
- int i=0,j=0;
- while(*(str+i) != '\0'){
- if(*(str+i)>='A' && *(str+i)<='Z'){
- if(i==0 || *(str+(i-1))==' ' || *(str+(i-1))=='\t'){
- while(1){
- temp = (char *)realloc(temp, (j+1)*sizeof(char));
- *(temp+j) = *(str+i);
- i++;
- j++;
- if(*(str+i)==' ' || *(str+i)=='\0' || *(str+i)=='\t')
- break;
- }
- }
- }
- else
- i++;
- }
- *(temp+j) = '\0';
- return temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement