Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- char* unpack(char *input) {
- int i=0;
- int j=0;
- int ch;
- char* output = malloc(1000*sizeof(char));
- while(input[i]!=0) {
- if(input[i]=='[') {
- for(ch = input[i+1]; ch<=input[i+3]; ch++) {
- output[j]=ch;
- j++;
- }
- i=i+5;
- }
- else {
- output[j] = input[i];
- i++;
- j++;
- }
- }
- return output;
- }
- int main() {
- char input[]="hello [a-c] bello [d-k] aa";
- char input2[]="Wtf???";
- char* output = unpack(input2);
- printf("%s\n%s\n", input2, output);
- free(output);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement