I was doing one of the K&R exercises which is to write a loop equivalent for the following short program without using || or &&. Usually my solutions are pretty similar to the solution book answer or some of the solutions I can find on the web but this time it is very different. Am I way off with this solution?
toCode:for (i = 0; i < lim -1 && (c = getchar()) != '\n' && c != EOF; ++i) s[i] = c;
Code:i = 0; while (i < lim -1) if (c = getchar() != '\n') if (c != EOF) ++i; s[i] = c;