-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
36 lines (30 loc) · 955 Bytes
/
test.c
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
33
34
35
36
#include <stdio.h>
#include <string.h>
#define PACKET_SIZE 10
#define MAX_INPUT_SIZE (PACKET_SIZE + 1) // Including null terminator
int main() {
char packet[MAX_INPUT_SIZE];
// Continuous loop until EOF or error
while (1) {
// Read one packet of input
if (fgets(packet, MAX_INPUT_SIZE, stdin) == NULL) {
if (feof(stdin)) {
// End of input stream
printf("End of input stream reached.\n");
} else {
// Error reading input
printf("Error reading input.\n");
}
break;
}
// Process the packet (replace this with your logic)
printf("Packet: %s", packet);
// Check if the packet is smaller than PACKET_SIZE
if (strlen(packet) < PACKET_SIZE) {
// End of input reached
printf("End of input reached.\n");
break;
}
}
return 0;
}