After this declaration
char expression[20]={""},sub[20]={""};
all elements of the array sub
contain zeroes.
You changed elements of the array starting from the position 15
sub[15]=expression[15];
sub[16]=expression[16];
sub[17]=expression[17];
sub[18]=expression[18];
The elements before the position still store zeroes.
So this call of printf
printf("sub= %s",sub);
assumes that the array contains an empty string because it first character is the terminating zero character ''
.
Instead you could write
printf("sub= %s",sub + 15 );
Or you could change the assignments like
sub[0]=expression[15];
sub[1]=expression[16];
sub[2]=expression[17];
sub[3]=expression[18];
and then use
printf("sub= %s",sub);
Pay attention to that the second argument of this call of scanf
scanf("%[^
]%*c",&expression);
is incorrect. You have to write
scanf("%[^
]%*c",expression);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…