bingo!! I knew it was garbage memory, however I wasnt sure how to get rid of it :-),
Thanks,
although now I have one other issue, the output is perfect except that I get one extra output of blank characters:
Code:
Original Line: 10 10 10 20 22 34
Scrambled Line: AA AA AA BA BB BB
15 231 -12 354 7 44 19 22 11 -6 9 5 44 -3
Mean = 52 Count = 14
11 12 58 43 29 16 288 25 999 124 98
Mean = 154 Count = 11
Original Line: 22 31 16 7 88 1297 41
Scrambled Line: BB BA AC C DD ABDC BA
Original Line: //This is the output I dont want
Scrambled Line: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
Here is the function that is doing the work:
Code:
void Scramble( istream & inf, ofstream & outf )
{
char x;
int j = 0;
char aLine[60]={0};
//inf.getline(aLine, 60);
cout << " Original Line: ";
outf << " Original Line: ";
while(inf.peek() != '\n')
{
inf.get(x);
aLine[j] = x;
cout << aLine[j];
outf << aLine[j];
j++;
}
cout << endl;
outf << endl;
outf << " Scrambled Line: ";
cout << " Scrambled Line: ";
for(int i = 0; i <= 59; i++ )
{
if( aLine[i] == '0' || aLine[i] == '1')
aLine[i] = 'A';
if( aLine[i] == '2' || aLine[i] == '3' || aLine[i] == '4')
aLine[i] = 'B';
if( aLine[i] == '5' || aLine[i] == '6' || aLine[i] == '7')
aLine[i] = 'C';
if( aLine[i] == '8' || aLine[i] == '9')
aLine[i] = 'D';
cout << aLine[i];
outf << aLine[i];
}
cout << endl;
outf << endl;
}
int main ()
{
char x;
ifstream infile("lines.txt");
ofstream data("data.txt");
while(!infile.eof())
{
infile >> x;
if( x == 'S' )
Scramble( infile, data);
if( x == 'C' )
CFunc( infile, data );
}
data.close();
infile.close();
return (0);
}
Now I cant determine where the extra line of blank output is coming from at the end?
Not to mention all the B's.
any ideas anyone?
thanx.