Im trying to create a simple RLC program. Im n ot sure the best way about it, but im trying to to use to 20 character arrays. One to read in the characters to be compressed (buffer) and the other is used to as a check. Either way, the buffer[20] reads in from a file and is fine, but other array (outputs[20]) does not read anything in, so when i set the first element of outputs[0] = buffer[0], i get the first letter of buffer, followed by a gibberish, which throws off all calculations. Code is below:
int Readchar(ifstream& fileread)
{
char buffer[20];
char temp;
int space, count, length;
count = 0;
cout << fileread.peek() << endl;
while (fileread.peek() != EOF)
{
fileread >> buffer;
Checkbuffer(buffer);
count ++;
}
return 0;
}
int Checkbuffer(char buffer[])
{
char outputs[20];
int k, length, count, adj;
adj = 0;
count = 0;
length = strlen(buffer);
outputs[0] = buffer[0];
cout << outputs;
for (k = 1; k <= length; k++)
{
if (buffer[k] == outputs[k-1])
{
outputs[k] = buffer[k];
}
else
{
Outputstring(outputs,k);
}
}
return 0;
}
If anyone can suggest how to empty outputs[20] so it contains nothing, it would be appreciated.
Regards
Kevin