blob: f36c93471aa85dee2f00bd4601c6b2d61402d396 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
}
|