---
# System prepended metadata

title: 12109 - Text Editor 2
tags: [string]

---

# 12109 - Text Editor 2

>author: Utin
###### tags: `string`

---

## Brief
See the code below

## Solution 0

```c=
#include <stdio.h>
#include <string.h>

#define MAX_SIZE 1005

char input[MAX_SIZE];
char command[MAX_SIZE];


int main() {
    gets(input);
    gets(command);

    char* cursor = input;
    int op_len = strlen(command);

    for (int i = 1; i < op_len; i += 2) {
        if (command[i] == 'b') {
            if (cursor != input) {
                char temp[MAX_SIZE];
                strcpy(temp, cursor);
                cursor--;
                strcpy(cursor, temp);
                *(cursor + strlen(temp)) = '\0';
            }
        }
        else if (*cursor != '\0') cursor++;
    }

    printf("%s\n", input);
}
// By Utin
```

## Reference