1

Topic: Problem with a text output in dialogue text boxes

I work in a Visual C ++ 2012. There is class CSourceNUDialog: public CDialog class CSourceNuDialog: public CDialog {//... public: void setTextsIntoEdits (char *s1, char *s2, char *s3, char *s4, char *s5, char *s6, char *s7, char *s8);//...}; In this class there is a function setTextsIntoEdits: void CSourceNuDialog:: setTextsIntoEdits (char *s1, char *s2, char *s3, char *s4, char *s5, char *s6, char *s7, char *s8) {m_IDC_EDIT1.SetWindowTextA (s1); m_IDC_EDIT2.SetWindowTextA (s2); m_IDC_EDIT3.SetWindowTextA (s3); m_IDC_EDIT4.SetWindowTextA (s4); m_IDC_EDIT5.SetWindowTextA (s5); m_IDC_EDIT6.SetWindowTextA (s6); m_IDC_EDIT7.SetWindowsTextA (s7); m_IDC_EDIT8.SetWindowTextA (s8);} In causing function I write: CSourceNuDialog mySourceNuDialog (this); strcpy (s1, "a"); strcpy (s2, "b"); strcpy (s3, "c"); strcpy (s4, "d"); strcpy (s5, "e"); strcpy (s6, "f"); strcpy (s7, "g"); strcpy (s8, "h"); mySourceNuDialog.setTextsIntoEdits (s1, s2, s3, s4, s5, s6, s7, s8); mySourceNuDialog. DoModal (); And in a debugger in function setTextsIntoEdits on the first line m_IDC_EDIT1.SetWindowTextA (s1); the program fights with the error report: Debug Assertion Failed! Program: C:\Windows\system32\mfc110d.dll File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\winocc.cpp Line: 246 That it means? How to rectify this error?

2

Re: Problem with a text output in dialogue text boxes

Hello, RussianFellow, you wrote: RF> In causing function I write: RF> strcpy (s1, "a"); strcpy (s2, "b"); strcpy (s3, "c"); strcpy (s4, "d"); strcpy (s5, "e"); strcpy (s6, "f"); strcpy (s7, "g"); strcpy (s8, "h"); What is s1? Most likely, it is simple char* s1; as conducts to crash. Correct on CString s1 = "a", s2 = "b"... mySourceNuDialog.setTextsIntoEdits (s1, s2...); And it is even better to replace too in parameters char* s1 on const CString& s1. : However, even if there CString, all the same it is impossible to write to it through strcpy, only through CString s1; strcpy (s1.GetBuffer (strlen ("a")), "a"); but what for?

3

Re: Problem with a text output in dialogue text boxes

Hello, RussianFellow, you wrote: RF> I work in a Visual C ++ 2012. RF> That it means? How to rectify this error? https://msdn.microsoft.com/ru-ru/library/fwz35s59.aspx CDialog:: OnInitDialog () - did not forget?