Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <io.h>
- #include <stdlib.h>
- int main(int argc, char **argv)
- {
- char tab[2048] = {0};
- char *ptr;
- int lc;
- int i = 0;
- ptr = tab;
- if (argc == 2)
- {
- while (argv[1][i])
- {
- if (argv[1][i] == '>')
- ptr++;
- else if (argv[1][i] == '<')
- ptr--;
- else if (argv[1][i] == '+')
- (*ptr)++;
- else if (argv[1][i] == '-')
- (*ptr)--;
- else if (argv[1][i] == '.')
- _write(1, &(*ptr), 1);
- else if (argv[1][i] == '[' && *ptr == 0)
- {
- lc = 1;
- while (lc != 0)
- {
- if (argv[1][i] =='[')
- lc++;
- if (argv[1][i] == ']')
- lc--;
- i++;
- }
- }
- else if (argv[1][i] == ']' && *ptr != 0)
- {
- lc = 1;
- while (lc != 0)
- {
- if (argv[1][i] =='[')
- lc--;
- if (argv[1][i] == ']')
- lc++;
- i--;
- }
- }
- i++;
- }
- }
- else
- _write(1, "\n", 1);
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement