From: lied AT lucent DOT com Date: Mon, 20 Nov 2000 17:39:31 -0600 Original-From: lied AT marconi DOT ih DOT lucent DOT com Message-Id: <200011202339.RAA01581@w-lied.ih.lucent.com> To: djgpp AT delorie DOT com Subject: Re: And nary the twain shall meet... Newsgroups: comp.os.msdos.djgpp In-Reply-To: Organization: Lucent Technologies, Naperville, Illinois, USA Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk In article you write: >Hullo, folks: > >I have a text file- numbers, two decimal places, tab delimited. I'd like >to be able to import this info into a program, and assign each number as a >float. > >It seems like, using fin.getline, you can only pull the data in in char >format. Is there a way to take char format and convert it to float, or is >there some other import method I should be using? Looks like C++ ... if I understand your question, it might be as simple as not using getline: #include float f1, f2; while ( fin >> f1 >> f2 ) // Read 'em in { cout << f1 << "\t" << f2 << endl; // Dump 'em out } If the line is already in a character array, you can convert the array using sscanf(): #include float f1, f2; sscanf(buf, "%f\t%f", &f1, &f2); --