Filling a polybius square

How would I go about writing a function to fill a polybius square?

This is what I have so far, but would I need a double loop instead?

Also, I feel like I would need to increment something in order to "fill" the square.

1
2
3
4
5
6
7
8
9
10
11
12
13
void FillSquare(square s, string keyword) {
// should uppercase all letters in keyword
// change all Js to Is
// ignore nonletters
     int row;
     int col;
     for (s == s[row][col]) {
          toupper(keyword);
          if (keyword == 'J') {
               return 'I';
          }
     }
}
Ill formed for loop , toupper only works on chars not strings. What exactly is the 'Square' object? If anything maybe s.row and s.col? or is the square a vector of rows and columns?
The 'Square' object is an array of square[6][6]. It follows a polybius square* and fills it up based on the keyword entered.

You mentioned that toupper() only works on chars, what would you recommend for strings?

Would something like this work, or maybe transform()?

1
2
3
4
for(int i = 0; i <= keyword.length(); i++)
{
    keyword[i] = toupper(keyword[i]);
}



--
*http://en.wikipedia.org/wiki/Polybius_square
Topic archived. No new replies allowed.