NASM - The Netwide Assembler
NASM Forum => Example Code => Topic started by: nobody on October 28, 2008, 01:39:04 AM
-
How would I got about reading a set of integers, floats, and strings as ASCII characters from an input file? THere is one entry per line and the first line in the file says how many entries there are.
Afterwards, we must determine what type of entry has been 'read' (int, float, or string) and depending on the type, we must create 3 different files and store each respective type on each file. We CANNOT use fscanf to read the entries... we must use the floating point assembly instruction to help with the conversion.
My main concern is about distinguishing the kind of type being read and how to read the entries without using fscanf! Anyone has any ideas? I've heard it's best to read everything as floats and make the determination of each type afterward.
-
Don't double post.
http://sourceforge.net/forum/forum.php?thread_id=2449246&forum_id=167168 (http://sourceforge.net/forum/forum.php?thread_id=2449246&forum_id=167168)
-
if you have for example the following list: 1.2 534 word (float, integer and string)
then it's easy to distinguish, you just read each byte separately and check if there is a dot between the numbers.
so it's not hard to distinguish between float and integer.
And string is not hard either.
i assume that your strings contain at least on byte that isn't a number (!123 or just a word: hello)
then you just make a function where you compare if bytes are different than numbers. If bytes in a string are all numbers and strings is meant to be a string then you can't distinguish unless mby lentgh or some other thing.
Oliver;)