Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char** copy_text(char** Text,int n){
- char *sent;
- char **Text2= malloc(n* sizeof(char*));
- for(int i=0;i<n;i++){
- strcpy(sent,Text[i]);
- Text2[i]=sent;
- }
- return Text2;
- }
- void garbage_count(char** Text,int n) {
- int Count = 0, Count_of_words = 0;
- int size = 10;
- char **Text2=copy_text(Text,n);
- char **Words = malloc(10 * sizeof(char *));
- char *STRtoK;
- char *word;
- for(int i=0;i<n;i++){
- Count=0;
- STRtoK=strtok(Text[i], " ,.");
- while (STRtoK != NULL) {
- if (Count_of_words == size) {
- size += 10;
- Words = realloc(Words, size * sizeof(char *));
- }
- word = to_lower(STRtoK);
- if (strcmp(word, "garbage") == 0) {
- Count++;
- }
- STRtoK = strtok(NULL, " ,.");
- Count_of_words++;
- }
- if (Count == 0) {
- printf("Clear\n");
- } else {
- if (Count > 0 && Count < 6) {
- printf("Must be washed\n");
- } else {
- printf("It's a dump!\n");
- }
- }
- }
- print_text(Text2,n);
- printf("\n");
- print_text(Text,n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement