Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
tickeParsing.c
//gcc 5.4.0 #include <stdio.h> #include <string.h> unsigned char command[5]; unsigned char commandSize=0; void makeStream(char *dataStream) { unsigned char line [50]; scanf("%s", line); while(strcmp(line, "xxx") != 0){ //printf("%s\n", line); strcat(dataStream, line); scanf("%s", line); } printf("%s\n", dataStream); } void receiveChar(unsigned char dataByte){ //if we are receiving just command bytes if( commandSize > 0 ){ if( command[0] == 0x1b ){ if( dataByte = 0x21 ){ commandSize ++; command[0]=0; } } commandSize --; } else{ if( dataByte == 0x1b ){ commandSize = 1; command[0] = 0x1b; } else{ if( dataByte == 0x1d){ commandSize = 2; } else if( dataByte > 9 && dataByte < 125 ) printf("%c", dataByte); else printf("%x", dataByte); } } } unsigned char atohex(unsigned char asciiByte){ if( (asciiByte >= '0') && ( asciiByte <= '9') ) asciiByte -= 0x30; else{ if( (asciiByte >= 'A') && ( asciiByte <= 'F') ) asciiByte -= 0x37; } return asciiByte; } void sendDataStream(unsigned char *rawData){ unsigned char highByte, lowByte, dataByte; while( *rawData != '\0' ){ highByte = *rawData; rawData++; lowByte = *rawData; dataByte = (atohex(highByte) << 4) | (atohex(lowByte)); receiveChar(dataByte); rawData++; } } int main(void) { //unsigned char *dataFile; unsigned char dataStream[14000]; //printf("Hello, world!\n"); makeStream(dataStream); sendDataStream(dataStream); return 0; }
run
|
edit
|
history
|
help
0
merge two dice clay to head sport green globe attacked me seven of prime minister fired
pattern 12
Don't ignore warnings
CPTTRN_1
Midterm practice 2
Tern operators
date diff sample
Find a Node Sibling Test
Run code before/after main in C (GCC)
140114_CribaErasthotenes