Home > Back-end >  Fscanf formatted input, there is an empty string what should I do
Fscanf formatted input, there is an empty string what should I do

Time:03-01

Text content is: [abc123] | | [] [30]
The space may or may not have string,
The code below
 # include & lt; Stdio. H> 
# define NEGFMT "% [^]]"
# define DECFMT "% d
"Int main () {
Char a1 [10], a2 [10].
Int a3;
The FILE * fp.
Fp=fopen (" data1. TXT ", "r");
Fscanf (fp, "[]" NEGFMT "| | [" NEGFMT"] [" DECFMT "] ", a1, a2, & amp; A3);
Printf (" % s \ n \ n % s % d ", a1, a2, a3);
return 0;
}

The final output is
Abc123

0
Dear leaders, how to keep my a3 accurately, because it is the university curriculum design, unable to change the text content, troublesome everybody bosses
  • Related