Warnings
1>..\Venext6\External Sub Functions\hospital\Hsglob.c(175): warning C4047: 'function': 'tm *const ' differs in levels of indirection from 'tm **'
1>..\Venext6\External Sub Functions\hospital\Hsglob.c(175): warning C4024: 'localtime_s': different types for formal and actual parameter 1
1>..\Venext6\External Sub Functions\hospital\Hsglob.c(175): warning C4047: '=': 'tm *' differs in levels of indirection from 'errno_t'
Warnings and error
1>..\Venext6\External Sub Functions\hospital\Hsglob.c(180): warning C4047: 'function': 'std::rsize_t' differs in levels of indirection from 'char *'
1>..\Venext6\External Sub Functions\hospital\Hsglob.c(180): warning C4024: 'strcpy_s': different types for formal and actual parameter 2
1>..\Venext6\External Sub Functions\hospital\Hsglob.c(180): error C2198: 'strcpy_s': too few arguments for call
Situation 3
strcpy_s(strrchr(filnam, '.'), ".bin"); (L270)
Warnings and error
1>..\Venext6\External Sub Functions\hospital\Hsglob.c(270): warning C4047: 'function': 'std::rsize_t' differs in levels of indirection from 'char [5]'
1>..\Venext6\External Sub Functions\hospital\Hsglob.c(270): warning C4024: 'strcpy_s': different types for formal and actual parameter 2
1>..\Venext6\External Sub Functions\hospital\Hsglob.c(270): error C2198: 'strcpy_s': too few arguments for call
You seem to have your first and second arguments reversed.
Also: You declare timeinfo to be a tm*, so obviously &timeinfo is a tm**. Obviously, you need to simply pass in a tm* - presumably, just timeinfo.
Situation 2:
If you look at the documentation for strcpy_s, you'll see that the second argument should be an rsize_t, not a char*. To fix it, pass the correct arguments in.
Situation 3:
Same as situation 2.
For all 3 situations:
When your compiler is telling you that you're not passing the right types of arguments into standard library functions, you should look at the documentation for those functions, to understand how they work, and what arguments to pass in.
#include <time.h>
// using the Microsoft library
void get_time( char* buffer, size_t size )
{
time_t rawtime;
// struct tm* timeinfo;
struct tm timeinfo ; // ****** we need to provide the tm object
time( &rawtime );
// timeinfo* = localtime_s( &timeinfo, &rawtime ); // (L175)
// "The implementation of localtime_s in Microsoft CRT is incompatible with the C standard
// since it has reversed parameter order and returns errno_t." - cppreference
// MSDN: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/localtime-s-localtime32-s-localtime64-s?view=msvc-160const errno_t result = localtime_s( &timeinfo, &rawtime ) ;
if( result == 0 ) strftime( buffer, size, "%I:%M:%S %p", &timeinfo );
else buffer[0] = 0 ;
}