Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void deleteword(char str[],int num){
- char s[255];
- int count=1;
- s[0]='\0';
- char *token = strtok (str, " ");
- while (token !=NULL)
- {
- if (count != num) { strcat (s,token); strcat (s," "); }
- token = strtok(NULL," ");
- ++count;
- }
- strcpy(str,s);
- }
- int main(){
- char str[255];
- printf("Type string: ");
- gets(str);
- int n;
- while(true){
- printf("\nType word number(0 to exit): ");
- scanf("%d",&n);
- if(n==0){
- break;
- }
- deleteword(str,n);
- for(int i=0;i<strlen(str);i++){
- printf("%c",str[i]);
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment