Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //just wc the output. And subtract one, for the EOF :-)
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char** argv)
- {
- char c;
- while((c=getchar())!= EOF){
- if(c=='('){
- int len /*= readint()*/;
- scanf("%d", &len);
- getchar();//discard x
- int i /*= readint()*/;
- scanf("%d", &i);
- getchar();//discard )
- char* buf = malloc((len + 1) * (sizeof(char)));
- if (buf == NULL) return -1;
- int s = fread(buf, 1, len, stdin);
- if (s != len) return -2;
- buf[len]='\0';//this works, because sizeof(buf)=len+1.
- for(;i>0;i--) printf("%s", buf);
- free(buf);
- }else{putchar(c);}
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement