Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Exercise 2-2.
- * Write a loop equivalent to the for loop above without using && or ||.
- */
- #include <stdio.h>
- #include <limits.h>
- #include <float.h>
- #define MAX 100
- int
- main() {
- int c, i = 0;
- int lim = MAX;
- char s[MAX];
- while (i < lim - 1) {
- if ((c = getchar()) != '\n') {
- if (c != EOF) {
- s[i++] = c;
- continue;
- }
- }
- break; /* if any of the above conditions failed, break the loop */
- }
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment