String Array homework help

Hi, this is my first post so forgive me if Im missing something
anyway I have to write a sudoku program in C++ for my comp sci class
I was a string array that looks like this

string origGame[] = {
"000120000",
"007005000",
"006009410",
"068050002",
"700208003",
"500040970",
"049800500",
"000700300",
"000091000",
};

and what I need to do is write a function that will output it to look like this

- - - | 1 2 - | - - -
| |
- - 7 | - - 5 | - - -
| |
- - 6 | - - 9 | 4 1 -
------+-------+------
- 6 8 | - 5 - | - - 2
| |
7 - - | 2 - 8 | - - 3
| |
5 - - | - 4 - | 9 7 -
------+-------+------
- 4 9 | 8 - - | 5 - -
| |
- - - | 7 - - | 3 - -
| |
- - - | - 9 1 | - - -

Basically I need to change all the 0's into -'s and divide it into 3x3 squares I dont really know anything about arrays or string and my knowledge of C++ is pretty basic, any help is appreciated
what you'll need is.

1. A for loop to go through the array.

2. An if statement to change the 0's into -'s

3. A statement to set the width of the lines so that they line up properly.

4. An output statement to output all of the numbers.

5. A Function named whatever you want that will take the parameters needed.

Thanks for the reply, my professor gave us this function

void displayGame(string b[]) {
for (int row = 0; row < GAMESIZE; row++)
cout << b[row] << endl;
}
}

where GAMESIZE is a global constant int = 9

this displays the array as

000120000
007005000
006009410
068050002
700208003
500040970
049800500
000700300
000091000

so what I guess Im asking is how can go through each string to find the 0's instead of the array, sorry if Im not clear on what Im asking, like I said Im really not familiar with strings or arrays
You can use the string's length function to determine the number of characters and you can use the at function to get a particular character.
Topic archived. No new replies allowed.