Bill
11-03-2001, 04:57 PM
ok i need to somehow read from an input file, so if its a number it stores
the number or if its a char it stores the char
the number or if its a char it stores the char
|
Click to See Complete Forum and Search --> : Reading From Input File A Float And A Char Bill 11-03-2001, 04:57 PM ok i need to somehow read from an input file, so if its a number it stores the number or if its a char it stores the char Danny Kalev 11-03-2001, 09:00 PM you can find examples here: http://gethelp.devx.com/techtips/cpp_pro/10min/2001/june/10min0601.asp Danny Bill wrote: > > ok i need to somehow read from an input file, so if its a number it stores > the number or if its a char it stores the char James Curran 11-04-2001, 12:58 AM First of all, we need to know what you mean by "a number". Is it in ASCII or binary? (e.g. 1234 is "31 32 33 34" in ASCII but "04 D2" as an integer in binary, and something else entirely as a float in binary) . I'm gonna guess that all input is in ascii, because it's easier to describe. First read a block of the file as characters. Look at the first few characters. Decide, by some means which must be unique to your particular program, if those characters are numbers or not. If they are numbers, convert the character to numbers using atoi() or atof(). You'll note that I skipped over the part that you most wanted to know about, but that's the part I really can't help you there. Only you know what's in those files, and what they mean. Say, for example, you had a file of business names and their revenues. If you saw "Micr", you'd say, those are characters, so this must be a character string (say "Microsoft"). On the other hand, you might see the character "1800" and those are numbers so this must be a number ---- except to could be the company "1800-Flowers" which means to should be read as a character string. -- Truth, James Curran www.NJTheater.com (Professional) www.NovelTheory.com (Personal) www.BrandsForLess.Com (Day Job) "Bill" <snugglebud@adelphia.net> wrote in message news:3be46833$1@147.208.176.211... > > ok i need to somehow read from an input file, so if its a number it stores > the number or if its a char it stores the char devx.com
Copyright Internet.com Inc. All Rights Reserved |