Locale breaks scanf()
Hello,
I've detected a strange bug when using setlocale(). The conversion
from strings to double for instance using scanf() is broken.
I have installed libc6 Version 2.0.7.19981211-6. This problem doesn't
occure at home on my clean slink system. Here is a very small
code example:
#include <locale.h>
#include <stdio.h>
void main(void)
{
int i;
double d;
char *string = "0.5";
setlocale (LC_ALL, "");
i = sscanf(string, "%lg", &d);
printf("%s is converted to %g (%i input items assigned)\n", string, d, i);
}
I compiled it with
# Makefile for scantest.c
NAME=scantest
CFLAGS=-g -O2 -Wall
LDFLAGS=-s
$(NAME): $(NAME).o
$(NAME).o: $(NAME).c
clean:
rm -rf *.o *~
On my system I get the output:
> scantest
0.5 is converted to 0 (1 input items assigned)
Could somebody explain this?
Kind regards
Andreas.
PS: I'm away until next Tuesday, if there are further questions to that
problem.
Reply to: