Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2-4 does not terminate #17

Open
swy20190 opened this issue Apr 7, 2020 · 0 comments
Open

2-4 does not terminate #17

swy20190 opened this issue Apr 7, 2020 · 0 comments

Comments

@swy20190
Copy link

swy20190 commented Apr 7, 2020

I find the program does not terminate on Windows.
But the following code works:

void squeeze(char s1[], char s2[])
{
    int i=0;//s1 ptr
    char tmp[MAXLINE];
    int k=0;//tmp ptr
    while(s1[i]!='\0'){
        int find_flag = 0;
        int j=0;//s2 ptr
        while(s2[j]!='\0'){
            if(s1[i]==s2[j]){//match!
                find_flag=1;
                break;
            }
            j++;
        }
        if(find_flag==0){
            tmp[k]=s1[i];
            k++;
        }
        i++;
    }
    tmp[k]='\0';
    for(int ii=0;ii<k+1;ii++)
        s1[ii]=tmp[ii];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant