Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- int main(int argc, char *argv[])
- {
- int s = 0, i, counter = 1;
- char c, *chars;
- if(strcmp(argv[1], "e") == 0)
- {
- c = getchar();
- if(c != '\n')
- {
- s++;
- chars = (char *)malloc(s * sizeof(char));
- chars[s-1] = c;
- } else
- {
- printf("\n");
- return 0;
- }
- c = getchar();
- while(c != '\n')
- {
- s++;
- chars = (char *)realloc(chars, s * sizeof(char));
- chars[s-1] = c;
- c = getchar();
- }
- chars[s] = '\0';
- for(i = 0; i < s; i++)
- {
- if(chars[i] == chars[i+1] && i < s-1)
- {
- counter++;
- } else
- {
- printf("%d%c", counter, chars[i]);
- counter = 1;
- }
- }
- } else if(strcmp(argv[1], "d") == 0)
- {
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement