// Online C compiler to run C program online
#include <stdio.h>
#include <string.h>
void process(char *b, int size){
static char buffer[512];
static int count = 0;
char tmp[128];
int i;
memcpy(buffer + count, b, size);
count += size;
int start = 0;
for (i = 0; i < count; i++){
if (buffer[i] == '\n'){
memcpy(tmp, buffer + start, i - start);
tmp[i-start] = 0;
//String s(tmp);
//Serial.println(s);
printf("%s\n",tmp);
start = i + 1;
}
}
for (i = start; i < count; i++){
buffer[i - start] = buffer[start];
}
count = count - start;
}
int main() {
char s1[] = "{'address':'24:58:7c:d3:87:de', 'rssi':-83, 'man_data':'2A', 'tick': 9224887823}\n{'address':'24:58:7c:d3:87:de', 'rssi':-84, ";
char s2[] = "aaa\nbbb";
char s3[] = "ccc\nddd\n";
// Write C code here
//printf("Try programiz.pro");
process(s1, strlen(s1));
process(s2, strlen(s2));
process(s3, strlen(s3));
return 0;
}
Ly8gT25saW5lIEMgY29tcGlsZXIgdG8gcnVuIEMgcHJvZ3JhbSBvbmxpbmUKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCnZvaWQgcHJvY2VzcyhjaGFyICpiLCBpbnQgc2l6ZSl7CiAgc3RhdGljIGNoYXIgYnVmZmVyWzUxMl07CiAgc3RhdGljIGludCBjb3VudCA9IDA7CgogIGNoYXIgdG1wWzEyOF07CiAgaW50IGk7CgogIG1lbWNweShidWZmZXIgKyBjb3VudCwgYiwgc2l6ZSk7CiAgY291bnQgKz0gc2l6ZTsKCiAgaW50IHN0YXJ0ID0gMDsKICBmb3IgKGkgPSAwOyBpIDwgY291bnQ7IGkrKyl7CiAgICBpZiAoYnVmZmVyW2ldID09ICdcbicpewogICAgICBtZW1jcHkodG1wLCBidWZmZXIgKyBzdGFydCwgaSAtIHN0YXJ0KTsKICAgICAgdG1wW2ktc3RhcnRdID0gMDsKICAgICAgLy9TdHJpbmcgcyh0bXApOwogICAgICAvL1NlcmlhbC5wcmludGxuKHMpOwogICAgICBwcmludGYoIiVzXG4iLHR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