[Kstars-devel] stupd C++ question
Jason Harris
kstars at 30doradus.org
Mon Sep 1 16:03:05 CEST 2003
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
--
KStars: A KDE Planetarium
http://edu.kde.org/kstars
More information about the Kstars-devel
mailing list