It is impossible to find out if the statement

Here is the code I'm working with, it checks the input "b" and should output "Y" if there was anything else in it.

Please, no one asks why I decided to use "Y" for a false value.

> , < +++++ +++++ [ > ----- ---- < - ] > ----- --- < [ > +++++ +++++ [ > +++++ +++ < - ] > +++++ ++++ < . < ] 

I would like the equivalent

 char c; c = getchar(); if (c == 'b') putchar('Y'); 

I do not get any output (sent it to a file and entered it, as well as nothing on the screen), regardless of what I entered into the program

+4
source share
2 answers

Your problem is that when you reach the second loop, you always have a zero value in the current cell, so your second loop never starts. You must be another cell on the right to get the result of your changes on the tab, and then you need to do the work only if the value is zero (as opposed to loops that will only work if the value is not zero).

To make a condition, I would suggest to grab something from the site with some code that someone else came up with ( an example I found ).

Anyway, this is the code I came across to solve your problem:

 , 7 * 7 * 7 = 98 = 'b' > +++++ ++ [ > +++++ ++ [ << -- >> - ] < - ] < expect everything to be zero here [ >+ >+ <<- ] > [ <+ >- ] + > [ <- >[-] ] < [ < >> [-] (11 * 8) plus 1 = 89 = 'Y' +++++ +++++ + [ << +++++ +++ >> - ] << + . > - ] 
+7
source

After almost 2 years, you probably won't need it anymore, but here is my version of the if-else statement:

 +++++ +++++ +++++ +++++ +++++ +++++ +++ (this is the value you want to check, in this case it the "!") > , < (then you take input an char to compare) [ - > - < ] (after that you have to check if their ascii values are the same) >> (and initialize the answer on "true") +++++ +++++ +++++ +++++ +++++ +++++ +++++ < [ - > ] > . (if "false", this loop will be executed and the answer won't be printed) 

Hope this will be useful to someone today.: D

+8
source

Source: https://habr.com/ru/post/1499288/


All Articles