Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- char stoparray[5]={'s','t','o','p',};
- char *buffer;
- size_t buffer_sz = 100;
- size_t c;
- char run ='y';
- buffer = (char *)malloc(buffer_sz * sizeof(char));
- if( buffer == NULL)
- {
- printf("not able to get mem for buffer\n");
- exit(1);
- }
- // another means of getttimg lengthb
- //size_t c = strlen (buffer);
- int ct=0,flag=0;
- /*
- printf("%zu characters were read.\n",c);
- printf("You typed: '%s'\n\n",buffer);
- for(int d=0;d<c;d++)
- printf("%c ",buffer[d]);
- printf("\n\n");
- for(int d=0;d<4;d++)
- printf("%c ",stoparray[d]);
- printf("\n\n");
- **/
- while(run=='y')
- {
- printf("add whatever \n");
- c = getline(&buffer,&buffer_sz,stdin);
- printf("You typed: '%s'\nct=%d\n",buffer,ct);
- while(ct<4 ){
- for(int a=0;a<c;a++){
- if( stoparray[ct] == buffer[a]){
- printf("found %c : %c \n",
- buffer[a],stoparray[ct]);
- flag++;
- }
- if(flag == 4) {
- printf("found\n"
- "flag = %d\n"
- "ct=%d\n",flag,ct);
- break; }
- }// end for
- ct++;
- } // end while
- if(flag == 4)
- run='n';
- else
- {
- flag=0;
- ct=0;
- }
- } //end while
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement