<...>
typedef struct
{
int index;
char com1[3];
char type1;
char val1[8];
char type2;
char val2[8];
} src_line;
typedef struct
{
int_var* INTEGER;
int integer_size;
flt_var* FLOAT;
int float_size;
str_var* STRING;
int string_size;
src_line* SOURCE;
int src_count;
} _warehouse;
_warehouse warehouse;
int add_source_line(char line[255])
{
/* ФОРМАТ КОМАНДЫ
┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐
│N ││N ││N ││ ││C ││C ││C ││ ││T ││ ││V ││V ││V ││V ││V ││V ││V ││V ││ ││T ││ ││V ││V ││V ││V ││V ││V ││V ││V │
└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘
┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐┌──┐
│00││01││02││03││04││05││06││07││08││09││10││11││12││13││14││15││16││17││18││19││20││21││22││23││24││25││26││27││28│
└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘└──┘ */
warehouse.SOURCE = realloc(warehouse.SOURCE, (++warehouse.src_count) * sizeof(src_line));
char str[3];
strncpy(str, line, 3);
sscanf(str, "%X", &warehouse.SOURCE[warehouse.src_count - 1].index);
strncpy(warehouse.SOURCE[warehouse.src_count - 1].com1, line + 4, 3);
printf("%s\t", warehouse.SOURCE[warehouse.src_count - 1].com1);
warehouse.SOURCE[warehouse.src_count - 1].type1 = line[8];
strncpy(warehouse.SOURCE[warehouse.src_count - 1].val1, line + 10, 8);
warehouse.SOURCE[warehouse.src_count - 1].type2 = line[19];
strncpy(warehouse.SOURCE[warehouse.src_count - 1].val2, line + 22, 8);
//printf("%i\t", warehouse.SOURCE[warehouse.src_count - 1].index);
printf("%s\t", warehouse.SOURCE[warehouse.src_count - 1].com1);
//printf("%c\t", warehouse.SOURCE[warehouse.src_count - 1].type1);
//printf("%s\t", warehouse.SOURCE[warehouse.src_count - 1].val1);
//printf("%c\t", warehouse.SOURCE[warehouse.src_count - 1].type2);
//printf("%s", warehouse.SOURCE[warehouse.src_count - 1].val2);
printf("\n");
return 1;
}
Первый printf выводит правильно считанные 3 символа. Второй printf говорит, что com1 поглотил весь остальной остаток строки.
Почему так и как исправить?