Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- int num=0;
- char *firstword(char *string, char array[]);
- int main(void){
- char *ptr;
- char array[40];
- ptr=firstword("hello how are you?", array);
- while(*ptr){
- printf("%c", *ptr);
- ptr++;
- }
- printf("\n");
- return 0;
- }
- char *firstword(char *string, char array[]){
- char *ptr=string;
- char *ptr2=array;
- int i;
- while(!isspace(*ptr)){
- *ptr2=*ptr;
- ptr2++;
- ptr++;
- num++;
- }
- *ptr2='\0';
- for(i=0; i<num; i++){
- ptr2--;
- }
- return ptr2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement