Click here to Skip to main content
15,913,587 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: memory leak Pin
Kevin McFarlane13-Nov-05 4:22
Kevin McFarlane13-Nov-05 4:22 
AnswerRe: memory leak Pin
Joe Woodbury11-Nov-05 20:19
professionalJoe Woodbury11-Nov-05 20:19 
QuestionCallback with "object" parameter fails Pin
TriLogic7-Nov-05 10:39
TriLogic7-Nov-05 10:39 
QuestionC++ console Pin
iamboy7-Nov-05 9:05
iamboy7-Nov-05 9:05 
AnswerRe: C++ console Pin
Christian Graus7-Nov-05 9:50
protectorChristian Graus7-Nov-05 9:50 
QuestionAccessing control from another file Pin
Eran6-Nov-05 22:49
Eran6-Nov-05 22:49 
AnswerRe: Accessing control from another file Pin
Christian Graus7-Nov-05 9:53
protectorChristian Graus7-Nov-05 9:53 
Questionfstream help Pin
afrodriguez6-Nov-05 15:54
afrodriguez6-Nov-05 15:54 
I need help using fstream...

i need to read a text file that has multiple lines, each line has the syntax:
'fname lname 01 02 03 04 05 06 07 08 08 10'
that is a first name space last name space and 10 test scores (separated by spaces). I then have to move all the data from one file to another except i have to add the average of the 10 scores to the end of each line...

I can read the full text and display as it is from one file to the other. The problem is i can't read just the numbers in order to get the average...here's the code i have so far...

#include <iostream>
#include <cstdlib>
#include <fstream>
#include <iomanip>

using namespace std;

#define INPUTFILE "HW660-In.txt"
#define OUTPUTFILE "HW660-Out.txt"

void rwFiles(ifstream& inSource, ofstream& outSource);

bool goOn();

void main()
{
dispHeader();

do
{
ifstream inStudentRecord;
ofstream outStudentRecord;

inStudentRecord.open(INPUTFILE);

if (inStudentRecord.fail())
{
cout<<"Opening input file failed.\n";
exit(1);
};

outStudentRecord.open(OUTPUTFILE);

if (outStudentRecord.fail())
{
cout<<"Opening output file failed.\n";
exit(1);
};

rwFiles(inStudentRecord, outStudentRecord);

inStudentRecord.close();
outStudentRecord.close();

}while(goOn());
}

void dispHeader()
{

void rwFiles(ifstream& inSource, ofstream& outSource)
{
char next;
int iGrade = 0, oGrade = 0;

inSource.get(next);

while (!inSource.eof())
{
if(next == '\n')
{
cout<<" The End"; //this adds "The End" at the end of every line.
};

cout<<next;
outsource<<next;
="" insource.get(next);
="" };=""
}

bool="" goon()
{
="" char="" calcmore="Y" ;
="" bool="" goon="true;

" cout<<"would="" you="" like="" to="" continue?="" (y="" n)="" ";
="" cin="">>calcMore;

switch (calcMore)
{
case 'Y': case 'y': ;break;
case 'N': case 'n': default: goOn = false;
}

return goOn;
}

So basically all my code does is reads exactly what is in the input file and displays it to the screen as well as copies it to the output file.

noob in need of help...
AnswerRe: fstream help Pin
Christian Graus6-Nov-05 15:58
protectorChristian Graus6-Nov-05 15:58 
GeneralRe: fstream help Pin
qfegd8-Nov-05 14:28
qfegd8-Nov-05 14:28 
AnswerRe: fstream help Pin
Jeremy Thornton12-Nov-05 14:03
Jeremy Thornton12-Nov-05 14:03 
GeneralRe: fstream help Pin
Jeremy Thornton12-Nov-05 13:13
Jeremy Thornton12-Nov-05 13:13 
QuestionUnicode File I/O problem Pin
scottwalk5-Nov-05 16:56
scottwalk5-Nov-05 16:56 
AnswerRe: Unicode File I/O problem Pin
Jeremy Thornton12-Nov-05 16:14
Jeremy Thornton12-Nov-05 16:14 
QuestionC++ object in C Pin
djtosh5-Nov-05 15:53
djtosh5-Nov-05 15:53 
AnswerRe: C++ object in C Pin
toxcct6-Nov-05 0:29
toxcct6-Nov-05 0:29 
AnswerRe: C++ object in C Pin
Andre xxxxxxx17-Jan-06 0:11
Andre xxxxxxx17-Jan-06 0:11 
Questionquery about giving inputs thru keboard Pin
bug1015-Nov-05 1:49
bug1015-Nov-05 1:49 
AnswerRe: query about giving inputs thru keboard Pin
Christian Graus6-Nov-05 14:05
protectorChristian Graus6-Nov-05 14:05 
QuestionTrain free @Microsoft Pin
vikas amin4-Nov-05 22:43
vikas amin4-Nov-05 22:43 
QuestionHow to set initial size of SDI window? Pin
SheriMarie4-Nov-05 4:57
SheriMarie4-Nov-05 4:57 
Questionwant to include &lt;windows.h&gt; in windows forms app Pin
9ine4-Nov-05 4:49
9ine4-Nov-05 4:49 
AnswerRe: want to include &amp;lt;windows.h&amp;gt; in windows forms app Pin
Sheng Jiang 蒋晟4-Nov-05 7:10
Sheng Jiang 蒋晟4-Nov-05 7:10 
GeneralRe: want to include &amp;amp;lt;windows.h&amp;amp;gt; in windows forms app Pin
9ine6-Nov-05 22:43
9ine6-Nov-05 22:43 
GeneralRe: want to include &amp;amp;lt;windows.h&amp;amp;gt; in windows forms app Pin
9ine7-Nov-05 0:15
9ine7-Nov-05 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.