Home > Software engineering >  Atof transformation is affected by system language setting
Atof transformation is affected by system language setting

Time:10-11

Transformed the atof (), if the point of system is set to the ". ", if set to a comma, does not have a problem when the system language is Chinese, but if the results of the system language to English will return an error, someone had a similar problem or know the possible reason? Thank you for the

CodePudding user response:

Engineering is the Unicode character set?

CodePudding user response:

reference 1st floor lx624909677 response:
engineering is the Unicode character set?


Is not the

CodePudding user response:


 # include & lt; stdio.h> 
# include & lt; Ctype. H>
# include & lt; string.h>

Char token_buf [128].
Int state;
Int start;
Char cbuf [128].
Int forward=1;
Void back () {
The forward -;
}
Void next () {
Forward + +;
}
Char * gettoken () {
Int I, j=0;
For (I=start; i <=forward; I + +) {
Token_buf [j++]=cbuf [I];
}
Token_buf [j]='\ 0';
Return token_buf;
}
Char nextchar () {
Forward + +;
Return cbuf (forward);
}
Char * nexttoken () {
char c;
State=12;
While (1) {
The switch (state) {
Case 12:
C=nextchar ();
If (c=='-' | | c=='+')
Start=forward;
Else if (isdigit (c)) {
If (start==1) start=forward;
State=13;
} else {
Start=1;
The next ();
}
break;
Case 13:
C=nextchar ();
If (isdigit (c))
State=13;
Else if (c=='e' | | c=='e')
State=16;
Else if (c==')
State=14;
The else
State=19;
break;
Case 14:
C=nextchar ();
If (isdigit (c))
State=15;
break;
Case 15:
C=nextchar ();
If (isdigit (c))
State=15;
Else if (c=='e' | | c=='e')
State=16;
The else
State=19;
break;
Case 16:
C=nextchar ();
If (isdigit (c))
State=18;
Else if (c=='+' | | c=='-')
State=17;
break;
Case 17:
C=nextchar ();
If (isdigit (c))
State=18;
break;
Case 18:
C=nextchar ();
If (isdigit (c))
State=18;
The else
State=19;
break;
Case 19:
The back ();
Return gettoken ();
}
}
}
Int main () {
The fgets (cbuf, 128, stdin);
If (=='\ n' cbuf [strlen (cbuf) - 1)) cbuf [strlen (cbuf) - 1)=0.
While (1) {
Start=1;
Printf (" % s \ n ", the nexttoken ());
If (forward & gt;=(int) strlen (cbuf) - 1) {
return 0;
}
}
}
//input: 12.3 * * * * * * * * * klj12.2 e2jj778
//output:
//12.3
//12.2 e2
//778
//

CodePudding user response:

refer to the second floor helly100 response:
Quote: refer to 1st floor lx624909677 response:

Engineering is the Unicode character set?


Not

Try it with the unicode character set, Chinese characters in English under the operating system does not recognize
  • Related