[Kstars-devel] stupd C++ question

Jasem Mutlaq mutlaqja at ikarustech.com
Mon Sep 1 15:31:00 CEST 2003


Hello,

try this

sscanf( line, "%2d%2d%05g", &rah, &ram, &ras );

- Jasem

On Monday 01 September 2003 14:03, Jason Harris wrote:
> Hello,
>
> I am trying to write a straight C++ program to parse the star catalog,
> so I can add some additional genitive names I found.  I usually use
> fortran for these little 20-line programs, but it isn't flexible enough
> for this purpose.  I'm afraid I am a bit lost without my Qt/KDE
> crutches! :)
>
> Why doesn't this simple program work?
>
> -----------------------------
> #include <iostream>
> #include <cstring>
> using namespace std;
>
> int main() {
>   int rah, ram;
>   float ras;
>   char *line = "064509.25";
>
>   sscanf( line, "%2d%2d%5.2f", &rah, &ram, &ras );
>
>   cout << rah << ":" << ram << ":" << ras << endl;
> }
> -----------------------------
> When I run it, I get:
> 6:45:3.98821e-34
>
> Why isn't the third field getting set to "9.25"?
>
> thanks for any ideas,
> Jason



More information about the Kstars-devel mailing list