my string is char loc[3][3];
i need help setting every variable to a space
my string is char loc[3][3];
i need help setting every variable to a space
A space char is ascii 32 on most PC's. If you don't have an ascii table yet, you can easily download one from the net. Very handy for anyone who programs.
If you mean a null char, then it's just '\0'. For both the form in general is
Code:for(row=0;row<R;row++) {//R=3 in your example for(col=0;col<C;col++) { //C=3 " " " and assign your char array[row][col] the value of either '\0' or 32 } }
No, don't go using magic numbers like 32. The only time you ever need an ASCII table is when debugging and looking at stuff in a memory viewer. If you're actually writing code then you should always be using actual characters.
In this case a space was asked for, so that means assigning a space character, e.g.Code:loc[i][j] = ' ';
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"