- #1
sandy.bridge
- 798
- 1
Homework Statement
Hello all. I have a function that is supposed to decode a string of integers and characters into an image. The function is not working 100%, and I cannot seem to figure out why.
Here is my code:
PHP:
void part5(char F[80][80], int Y, int Z) // function for q1p5.
{
cin >> noskipws;
int num_pixels = Y*Z;
int num_pixels_decoded = 0;
while (num_pixels_decoded < num_pixels)
{
int N, i = 0, count = 0;
char ch; char dy; while(i < Y){
cin >> N >> dy >> ch;
for (int k=0; k<N; k++)
{
F[i][k]=ch; cout << F[i][k];
count++; num_pixels_decoded++;
if (count == Z){cout << endl;i++; count = 0;}
}
}
cout << endl;
for(int x = 0; x < Y; x++)
{
for(int y = 0; y < Z; y++)
{
cout << F[x][y];
}
}cin >> skipws;
return;}
}
I believe the issue has something to do with assigning the array. The first cout << F[k] outputs the image perfectly; however, the second loop (which I made just to ensure that the array was indeed saving correctly), is not giving anything to the console. That is, cout << F[x][y]; does not do a thing.As an example:
If I input :22: 1:,1:;1:-1:.42: 1:,2:(2:-1:\1:)1:.39: 1:/8: 1:\37: 1:|10: 1:|36: 1:|10: 1:|35: 1:(1:,1:'1:"1:`1:.2: 1:,1:'1:"1:`1:.1:)34: 1::5: 1:\1:/5: 1:;34: 1:`1:.1