diff options
Diffstat (limited to '6.c')
-rw-r--r-- | 6.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -0,0 +1,32 @@ + +#include <stdio.h> + + +int +main() +{ + char buf[4]; + int c, n = 0; + + while ((c = fgetc(stdin)) != EOF) { + buf[n % 4] = c; + ++n; + + if (n >= 4 + && buf[0] != buf[1] && buf[0] != buf[2] && buf[0] != buf[3] + && buf[1] != buf[2] && buf[1] != buf[3] && buf[2] != buf[3]) + { + break; + } + } + + if (c == EOF) { + printf("No marker read in %d bytes\n", n); + return 1; + } + + printf("Marker read after %d bytes\n", n); + + return 0; +} + |