Article View: alt.comp.lang.learn.c-c++
Article #788Basic file I/O - flame away!!!
From: Bill Barnett
Date: Sat, 10 Jul 1999 00:00
Date: Sat, 10 Jul 1999 00:00
80 lines
2671 bytes
2671 bytes
Before you diehard flamers get started, I've read FAQ [15.4] and
understand the principal (I thought) but have still got the same
problem. I'm reading data in from a text file using the code below and
still get stuck in an infinite loop. I'm really not as dumb as this
dilemma would indicate!!! Any thoughts about this problem or my future
as a programmer are welcome.
Bill Barnett
"Unrepentant Ada programmer"
barnetwc@email.uc.edu
http://homepages.uc.edu/~barnetwc
Je parle un peu fran๏ฟฝais! - Anglophones go here -> translator.go.com
Check out the program specification if you like here;
http://www.cba.uc.edu/faculty/rokeyrs/cs321assignment2.htm
As you can see I've got a ways to go...
#include <string>
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
void main()
{
char F_Name[16];
char L_Name[16];
char C_Name[22];
char ch;
ifstream fin;
ofstream echo = "echo.txt";
fin.open("student.dat");
do // get file data
{
do // get line data
{
char ClassTitle[22];
fin >> F_Name >> L_Name;
// Correct capitalization
for (int i = 0; i < 16; i++)
{
if ((F_Name[i] >= 'A') && (F_Name[i] <= 'Z'))
F_Name[i] = F_Name[i] + 32;
}
F_Name[0] = F_Name[0] - 32;
for (int j = 0; j < 16; j++)
{
if ((L_Name[j] > 'A') && (L_Name[j] < 'Z'))
L_Name[j] = L_Name[j] + 32;
}
L_Name[0] = L_Name[0] - 32;
fin.get(ClassTitle, 22);
strcpy(C_Name, ClassTitle);
cout << L_Name << ", " << F_Name << " - " << C_Name << "\n";
echo << L_Name << ", " << F_Name << " - " << C_Name << "\n";
}
while (!fin.peek()== '\0');
}
while (fin >> ch);
fin.close();
}
The data file is;
zongjun zhang Data Structures
Marti Morthorst Data Structures
Anne Maseck Data Structures
SRIHARI KORTIKERE Programming for IS I
Jason Wilson Data Structures
Rhonda Rains Data Structures
Technical Details
Message-ID:
<3787F989.A3867A44@email.uc.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 114592,cea2866abe4eec88,start X-Google-Attributes: gid114592,public X-Google-Thread: fdcad,cea2866abe4eec88,start X-Google-Attributes: gidfdcad,public From: Bill Barnett <barnetwc@email.uc.edu> Subject: Basic file I/O - flame away!!! Date: 1999/07/10 Message-ID: <3787F989.A3867A44@email.uc.edu> X-Deja-AN: 499630824 Content-Transfer-Encoding: 8bit X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: newsabuse@remarQ.com X-Trace: 931658230.142.101 FC4FGIW.C7D90D844C qube-01.us-ca.remarq.com Organization: No thanks! MIME-Version: 1.0 NNTP-Posting-Date: Sun, 11 Jul 1999 01:57:10 GMT Newsgroups: alt.comp.lang.learn.c-c++,fr.comp.lang.c++