sprintf_s

  • Thread starter Thread starter W1EO
  • Start date Start date
W

W1EO

Guest
The following works when run as a single line “command”.

b1M->Items->Add((int)(MTD160P));


I would like to create and run that programmatically from within my C++ MS Visual Studio where i=1 and localbuf=”160”. I try this;


sprintf_s(Form1::b1M,sizeof(Form1::b1M),"b%dM->Items->Add((int)(MTD%sP))",i,localbuf);


I receive the following error:


1>c:\rms\rms trimode\12.03.00\secondtry\secondtry\Form1.h(34355): error C2664: 'sprintf_s' : cannot convert parameter 1 from 'System::Windows::Forms::ListBox ^' to 'char *'

1> No user-defined-conversion operator available, or

1> Cannot convert a managed type to an unmanaged type



Although this creates a string that looks identical to the single line ‘command’ above, it won’t accept the destination string. Form1 is my basic generated display and b1M is a listbox on that display. Obviously I don’t understand the format required for the destination string.

Help please.

Dave


I’m truly up against a stone wall. I am attempting to determine if a specific file has been recently written to by another program. My periodic recirculation loop finds a new file at startup (LastWriteTime is zero). If I manually transfer a new file it is also found immediately. If I transfer using Team Viewer from one computer to this one, the file is found immediately. However, if the other program creates/writes a new version of the file, my loop finds the first such file immediately but it only finds subsequent new files spasmodically. If I leave my program looping, it will usually find the new file after several minutes. If I examine the created/written file, I find it has indeed been updated with new data appended and a new date modified has been posted. Yet my loop returns the same ftWrite.dwHighDateTime value as previously returned. I suspect it is not truly reading the new Write Time. Why? if(interval==0) { if(_access_s("C:/RMS/RMS TRIMODE/LOGS/RMS Trimode_ADIF_201211.adi",00)==0)//ch

Continue reading...
 

Similar threads

Back
Top