Hi everybdoy,
I've read a few tutorials on static variables and functions, including the one on this site, and I think it makes sense to me. But I keep running into a memory problem. The class I use is this:from previous postts I think I've fixed most of the CString problems in the code. Now when I use one of the functions here:Code:class InBAF { private: static char location; static CString server; static CString file; public: static void SetLocation(char newloc) { location = newloc; } static void SetServerName(char location) { switch (location) { case 'T': server = "ftp.ca"; break; case 'M': server = "ftp.ca"; break; } } static void SetFileName(CString name) { file = name; } static CString GetServerName() { return server; } static char GetLocation() { return location; } static CString GetFname() { return file; } }; char InBAF::location = 'N'; CString InBAF::server; CString InBAF::file;Aside from the Visual part I get an error that memory could not be read and the file contain nothing, not even the > <. However, if I say display the contents in a text box control it displays the contents of name. and I can't step through with he debugger because there is an access violation problem with another function i nthe program that I haven't resolved yet, and don't know what causes it.Code:CListBox* pListSub = (CListBox*)GetDlgItem(IDLB_SUBDIR); CString name; pListSub->GetText((pListSub->GetCurSel()), name); FILE* out = fopen("h:\\gui\\selsub.txt", "w"); fprintf(out, ">%s<\n", name); InBAF::SetFileName(name);
If someone could take a look at the class for any problems that I don't know about please. Thanks in advance.



LinkBack URL
About LinkBacks



