Help wanted

Jane Liang JLiang@lgc.com
Mon Mar 17 16:44:00 GMT 2003


Hi, all:

I have a simple program(see below), it ran without any problem in sun (with
sun's compiler). However, when I compiled it in gcc on PC, it crashed at
line 13.  I tried to use strtok and some other string functions but none of
them seems works fine.  Does anyone know why?

Thanks!

Jane


Line 1    #include <stdlib.h>
Line 2    #include <stdio.h>
Line 3    #include <string.h>
Line 4
Line 5    int main()
Line 6    {
Line 7
Line 8      char *str = "0.12000, 0.0, 0.0";
Line 9      char *ptr;
Line 10     float  num;
Line 11
Line 12     ptr = strchr(str, ',');
Line 13     *ptr = '\0';
Line 14 
Line 15     num = atof(str);
Line 16
Line 17     return 0;
Line 18   }


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20030317/8416eb04/attachment.htm>


More information about the Gcc-help mailing list