Matrix form in VC++
I have a two dimensional array having elements of a matrix I want to display the content of the matrix on a edit control box while I am writting a dialog based project in VS2010 but the code I have added inside the button control is a s below.
void CtestCstrDlg::OnBnClickedButton1()
{
CString strTest(" "), strB,strC;
// TO开发者_如何转开发DO: Add your control notification handler code here
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
strB.Format(L"%d ", j);
strTest+=strB;
}
strTest+="\n";
}
m_edDisp.SetWindowTextW(strTest);
}
but I found that on runtime if I click on the button it only shows the content in a single line. How to get the square form like
0 1 2 3
0 1 2 3
0 1 2 3
0 1 2 3
? Please help me..
Try replacing strTest+="\n";
with strTest+="\r\n";
. Windows uses Carriage Return (ASCII 13, '\r') followed by Line Feed (ASCII 10, '\n') to designate a new line.
精彩评论