您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ strcpy_s函数代码示例

51自学网 2021-06-03 08:28:36
  C++
这篇教程C++ strcpy_s函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中strcpy_s函数的典型用法代码示例。如果您正苦于以下问题:C++ strcpy_s函数的具体用法?C++ strcpy_s怎么用?C++ strcpy_s使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了strcpy_s函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: MakeRtnData

void MakeRtnData(void * pConn,long reqno, unsigned long funcid, long errcode,const char * errInfo , const char * retbuf, long len,bool islast){	tagTradeErrorInfo *pErrInfo = new tagTradeErrorInfo();	pErrInfo->ErrorID = 0;	void * datahandle = NULL;	int iRowCount = 0;	if (errcode >= 0)	{		datahandle = YTData_NewData();		YTData_ConvertData(datahandle, retbuf, len);		iRowCount = YTData_GetRowCount(datahandle);		if (iRowCount > 0)		{			YTData_GotoBeginRow(datahandle);			pErrInfo->ErrorID = YTData_GetFieldInt(datahandle,"retcode");			if (pErrInfo->ErrorID < 0)			{				YTData_GetFieldString(datahandle,"comment",pErrInfo->ErrorMsg,sizeof(pErrInfo->ErrorMsg));			}		}	}	else	{		pErrInfo->ErrorID = errcode;		strcpy_s(pErrInfo->ErrorMsg, sizeof(pErrInfo->ErrorMsg), errInfo);	}	int i = 0;	switch(funcid)	{	case LOGIN:		if (errcode < 0 || pErrInfo->ErrorID < 0)  		{			pFuncList->Func_TradeAnsLogin(NULL,pErrInfo);					}		else  //正常返回		{			tagTradeAnsLogin* pPara = new tagTradeAnsLogin();			pPara->UserID = YTData_GetFieldInt(datahandle,"userid");			pPara->UserType = YTData_GetFieldInt(datahandle,"usertype");			iUserID = pPara->UserID;			//登陆成功之后,初始化连接池。连接池开始有maxconn/2 个连接      void* conn = pConn;        EnterCriticalSection(&secLock);       //for(int k=0;k<imaxConnects/2;k++)        //{       //  conn = YTConn_NewConn(ptrConfig);      //  if (YTConn_Connect(conn) >=0)      //  {      //    connLists.push_back(conn);      //    iCurConnects++;      //  }      //}        connLists.push_back(conn);      iCurConnects++;      LeaveCriticalSection(&secLock);        if(iCurConnects >= imaxConnects/2){ 			  pFuncList->Func_TradeAnsLogin(pPara,pErrInfo);      }			delete pPara;					}		break;	case QURELATED:		if (errcode < 0 || pErrInfo->ErrorID < 0)  		{			pFuncList->Func_TradeAnsQuRelated(NULL,0,pErrInfo,reqno,islast);		}		else  //正常返回		{			iRowCount = YTData_GetRowCount(datahandle); 			tagTradeAnsQuRelated* pPara = new tagTradeAnsQuRelated[iRowCount];			for (i=0;i<iRowCount;i++)			{				pPara[i].UserID = YTData_GetFieldInt(datahandle,"userid");				YTData_GetFieldString(datahandle,"user",pPara[i].User,sizeof(pPara[i].User));				pPara[i].AccID = YTData_GetFieldInt(datahandle,"accountid");				YTData_GetFieldString(datahandle,"accountalias",pPara[i].AccountName,sizeof(pPara[i].AccountName));				pPara[i].CounterID = YTData_GetFieldInt(datahandle,"counterid");				pPara[i].UsableMoney = YTData_GetFieldDouble(datahandle,"usablemoney");			}			pFuncList->Func_TradeAnsQuRelated(pPara,iRowCount,pErrInfo,reqno,islast);			delete []pPara;		}		break;	case QUMONEY:		if (errcode < 0 || pErrInfo->ErrorID < 0)  		{			pFuncList->Func_TradeAnsQuMoney(NULL,0,pErrInfo,reqno,islast);		}		else  //正常返回		{			iRowCount = YTData_GetRowCount(datahandle); 			tagTradeAnsQuMoney* pPara = new tagTradeAnsQuMoney[iRowCount];			for (i=0;i<iRowCount;i++)			{				pPara[i].UsableMoney = YTData_GetFieldDouble(datahandle,"usablemoney");//.........这里部分代码省略.........
开发者ID:hbi980,项目名称:ytnew,代码行数:101,


示例2: ExpandEnvironmentStringsA

// CConnectSTDMETHODIMP CConnect::OnConnection(IDispatch *pApplication, AddInDesignerObjects::ext_ConnectMode /*ConnectMode*/, IDispatch *pAddInInst, SAFEARRAY ** /*custom*/){	char BERTXLL[32] = "";		char RBin[MAX_PATH];	char Home[MAX_PATH];	char Install[MAX_PATH];	char XLLPath[MAX_PATH];	if (!CRegistryUtils::GetRegExpandString(HKEY_CURRENT_USER, RBin, MAX_PATH - 1, REGISTRY_KEY, REGISTRY_VALUE_R_HOME, true))		ExpandEnvironmentStringsA(DEFAULT_R_HOME, RBin, MAX_PATH - 1);	if (!CRegistryUtils::GetRegExpandString(HKEY_CURRENT_USER, Home, MAX_PATH - 1, REGISTRY_KEY, REGISTRY_VALUE_R_USER, true))		ExpandEnvironmentStringsA(DEFAULT_R_USER, Home, MAX_PATH - 1);	if (!CRegistryUtils::GetRegString(HKEY_CURRENT_USER, Install, MAX_PATH - 1, REGISTRY_KEY, REGISTRY_VALUE_INSTALL_DIR))		sprintf_s(Install, MAX_PATH, "");	int len = strlen(RBin);	if (len > 0)	{		if (RBin[len - 1] != '//') strcat_s(RBin, MAX_PATH - 1, "//");	}	// DERP#ifdef _WIN64	strcat_s(RBin, MAX_PATH, "bin//x64;");#else	strcat_s(RBin, MAX_PATH, "bin//i386;");#endif	// set path	int elen = ::GetEnvironmentVariableA("PATH", 0, 0);	int blen = strlen(RBin);	char *buffer = new char[blen + elen + 1];	strcpy_s(buffer, blen + elen + 1, RBin);	if (elen > 0)	{		::GetEnvironmentVariableA("PATH", &(buffer[blen]), elen);	}	::SetEnvironmentVariableA("PATH", buffer);	::SetEnvironmentVariableA("HOME", Home);	delete[] buffer;	// load xll#ifdef _DEBUG #ifdef _WIN64	sprintf_s(BERTXLL, 32, "BERT64D.xll");#else	sprintf_s(BERTXLL, 32, "BERT32D.xll");#endif#else#ifdef _WIN64	sprintf_s(BERTXLL, 32, "BERT64.xll");#else	sprintf_s(BERTXLL, 32, "BERT32.xll");#endif#endif	pApplication->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pApplication);	pAddInInst->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pAddInInstance);	::PathAddBackslashA(Install);	::PathCombineA(XLLPath, Install, BERTXLL);	CComQIPtr<Excel::_Application> app = m_pApplication;	if (app){		int rslt = SetCOMPtrs((void*)m_pApplication.p, (void*)this);		if (!rslt){			ATLTRACE("Already registered/n");		}		else if (rslt && strlen(XLLPath))		{			_bstr_t bstrPath(XLLPath);			VARIANT_BOOL vb = VARIANT_FALSE;			HRESULT hr = app->RegisterXLL(bstrPath, 1033, &vb);			if (SUCCEEDED(hr)){				if (vb) {					SetCOMPtrs((void*)m_pApplication.p, (void*)this);					// ATLTRACE("Loaded xll OK");				}				else {					// ATLTRACE("Succeeded but load returned false/n");				}			}			else {				// ATLTRACE("Failed with 0x%x/n", hr);			}		}	}//.........这里部分代码省略.........
开发者ID:wck01,项目名称:Basic-Excel-R-Toolkit,代码行数:101,


示例3: main

//.........这里部分代码省略.........#ifdef _MSC_VER                include_paths = _strdup(optarg);#else 				include_paths = strdup(optarg);#endif			} else {                char *old_paths = include_paths;				size_t len = strlen(old_paths) + 1 + strlen(optarg) + 1;                include_paths = malloc(len);#ifdef _MSC_VER				assert(include_paths != 0);                sprintf_s(include_paths, len, "%s%c%s", old_paths, PATH_SEP, optarg);#else				sprintf(include_paths, "%s%c%s", old_paths, PATH_SEP, optarg);#endif				free(old_paths);            }            break;        case 't':            for(i = 0; i < NUM_STYLE_OPTION_STRINGS; ++i) {                if(strcmp(optarg, style_option_strings[i].style_string) == 0) {                    sass_option_set_output_style(options, style_option_strings[i].output_style);                    break;                }            }            if(i == NUM_STYLE_OPTION_STRINGS) {                fprintf(stderr, "Invalid argument for -t flag: '%s'. Allowed arguments are:", optarg);                for(i = 0; i < NUM_STYLE_OPTION_STRINGS; ++i) {                    fprintf(stderr, " %s", style_option_strings[i].style_string);                }                fprintf(stderr, "/n");                invalid_usage(argv[0]);            }            break;        case 'l':            sass_option_set_source_comments(options, true);            break;        case 'm':            generate_source_map = true;            break;        case 'M':            sass_option_set_omit_source_map_url(options, true);            break;        case 'p':            sass_option_set_precision(options, atoi(optarg)); // TODO: make this more robust            if (sass_option_get_precision(options) < 0) sass_option_set_precision(options, 5);            break;        case 'v':            print_version(argv[0]);            return 0;        case 'h':            print_usage(argv[0]);            return 0;        case '?':            /* Unrecognized flag or missing an expected value */            /* getopt should produce it's own error message for this case */            invalid_usage(argv[0]);        default:            fprintf(stderr, "Unknown error while processing arguments/n");            return 2;        }    }    sass_option_set_include_path(options, include_paths ? include_paths : "");    if(optind < argc - 2) {        fprintf(stderr, "Error: Too many arguments./n");        invalid_usage(argv[0]);    }    int result;    if(optind < argc && strcmp(argv[optind], "-") != 0 && !from_stdin) {        if (optind + 1 < argc) {            outfile = argv[optind + 1];        }        if (generate_source_map && outfile) {            const char* extension = ".map";			size_t len = strlen(outfile) + strlen(extension) + 1;            char* source_map_file  = calloc(len, sizeof(char));#ifdef _MSC_VER            strcpy_s(source_map_file, (len*sizeof(char)), outfile);            strcat_s(source_map_file, (len*sizeof(char)), extension);#else			strcpy(source_map_file, outfile);			strcat(source_map_file, extension);#endif            sass_option_set_source_map_file(options, source_map_file);        }        result = compile_file(options, argv[optind], outfile);    } else {        if (optind < argc) {            outfile = argv[optind];        }        result = compile_stdin(options, outfile);    }    free(include_paths);    return result;}
开发者ID:driekus77,项目名称:sassc,代码行数:101,


示例4: LogVerbose

int verbTOC::DoWork(const char *nameOfInput){    LogVerbose("Indexing from '%s' into '%s.mct'", nameOfInput, nameOfInput);    MethodContextIterator mci;    if (!mci.Initialize(nameOfInput))        return -1;    int savedCount = 0;    TOCElementNode *head = nullptr;    TOCElementNode *curElem = nullptr;    while (mci.MoveNext())    {        MethodContext* mc = mci.Current();        TOCElementNode *nxt = new TOCElementNode(mci.MethodContextNumber(), mci.CurrentPos());        mc->dumpMethodMD5HashToBuffer(nxt->tocElement.Hash, MD5_HASH_BUFFER_SIZE);        if (curElem != nullptr)        {            curElem->Next = nxt;        }        else        {            head = nxt;        }        curElem = nxt;        savedCount++;    }    size_t maxLen = strlen(nameOfInput) + 5;    char *nameOfOutput = (char*)_alloca(maxLen);    strcpy_s(nameOfOutput, maxLen, nameOfInput);    strcat_s(nameOfOutput, maxLen, ".mct");    HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);    if (hFileOut == INVALID_HANDLE_VALUE)    {        LogError("Failed to open input 1 '%s'. GetLastError()=%u", nameOfOutput, GetLastError());        return -1;    }    DWORD written;    // Write out the signature "INDX" and then the element count    LARGE_INTEGER token;    token.u.LowPart = *(const int*)"INDX"; // cuz Type Safety is for languages that have good IO facilities    token.u.HighPart = savedCount;    if (!WriteFile(hFileOut, &token, sizeof(token), &written, nullptr) || written != sizeof(token))    {        LogError("Failed to write index header. GetLastError()=%u", GetLastError());    }    // Now just dump sizeof(TOCElement) byte chunks into the file.    // I could probably do this more efficiently, but I don't think it matters    DWORD chunkSize = sizeof(TOCElement);    for (curElem = head; curElem != nullptr; curElem = curElem->Next)    {        if (!WriteFile(hFileOut, &curElem->tocElement, chunkSize, &written, nullptr) || written != chunkSize)        {            LogError("Failed to write index element '%d'. GetLastError()=%u", curElem->tocElement.Number, GetLastError());            return -1;        }    }    // Now write out a final "INDX" to flag the end of the file...    if (!WriteFile(hFileOut, &token.u.LowPart, sizeof(token.u.LowPart), &written, nullptr) || (written != sizeof(token.u.LowPart)))    {        LogError("Failed to write index terminal. GetLastError()=%u", GetLastError());    }    LogInfo("Loaded %d, added %d to Table of Contents", mci.MethodContextNumber(), savedCount);    if (CloseHandle(hFileOut) == 0)    {        LogError("CloseHandle failed. GetLastError()=%u", GetLastError());        return -1;    }    if (!mci.Destroy())        return -1;    return 0;}
开发者ID:DrewScoggins,项目名称:coreclr,代码行数:83,


示例5: Assert

/** * @brief Load an animation.  This stores the compressed data, which instances of the animation can reference.   * Must be free'ed later with anim_free(). *  * @param real_filename Filename of animation * @param cf_dir_type  * @param file_mapped Whether to use memory-mapped file or not. *  * @details Memory-mapped files will page in the animation from disk as it is needed, but performance is not as good. * @return Pointer to anim that is loaded if sucess, NULL if failure. */anim *anim_load(const char *real_filename, int cf_dir_type, int file_mapped){	anim			*ptr;	CFILE			*fp;	int			count,idx;	char name[_MAX_PATH];	Assert( real_filename != NULL );	strcpy_s( name, real_filename );	char *p = strchr( name, '.' );	if ( p ) {		*p = 0;	}	strcat_s( name, ".ani" );	ptr = first_anim;	while (ptr) {		if (!stricmp(name, ptr->name))			break;		ptr = ptr->next;	}	if (!ptr) {		fp = cfopen(name, "rb", CFILE_NORMAL, cf_dir_type);		if ( !fp )			return NULL;		ptr = (anim *) vm_malloc(sizeof(anim));		Assert(ptr);		ptr->flags = 0;		ptr->next = first_anim;		first_anim = ptr;		Assert(strlen(name) < _MAX_PATH - 1);		strcpy_s(ptr->name, name);		ptr->instance_count = 0;		ptr->width = 0;		ptr->height = 0;		ptr->total_frames = 0;		ptr->keys = NULL;		ptr->ref_count=0;		anim_read_header(ptr, fp);		if (ptr->width < 0 || ptr->height < 0) {			Error(LOCATION, "Ani file %s has a faulty header and cannot be loaded.", name);		}		if(ptr->num_keys > 0){			ptr->keys = (key_frame*)vm_malloc(sizeof(key_frame) * ptr->num_keys);			Assert(ptr->keys != NULL);		} 					// store how long the anim should take on playback (in seconds)		ptr->time = i2fl(ptr->total_frames)/ptr->fps;		for(idx=0;idx<ptr->num_keys;idx++){			ptr->keys[idx].frame_num = 0;			cfread(&ptr->keys[idx].frame_num, 2, 1, fp);			cfread(&ptr->keys[idx].offset, 4, 1, fp);			ptr->keys[idx].frame_num = INTEL_INT( ptr->keys[idx].frame_num ); //-V570			ptr->keys[idx].offset = INTEL_INT( ptr->keys[idx].offset ); //-V570		}		cfread(&count, 4, 1, fp);	// size of compressed data		count = INTEL_INT( count );		ptr->cfile_ptr = NULL;		if ( file_mapped == PAGE_FROM_MEM) {			// Try mapping the file to memory 			ptr->flags |= ANF_MEM_MAPPED;			ptr->cfile_ptr = cfopen(name, "rb", CFILE_MEMORY_MAPPED, cf_dir_type);		}		// couldn't memory-map file... must be in a packfile, so stream manually		if ( file_mapped == PAGE_FROM_MEM && !ptr->cfile_ptr ) {			ptr->flags &= ~ANF_MEM_MAPPED;			ptr->flags |= ANF_STREAMED;			ptr->cfile_ptr = cfopen(name, "rb", CFILE_NORMAL, cf_dir_type);		}		ptr->cache = NULL;		// If it opened properly as mem-mapped (or streamed)		if (ptr->cfile_ptr != NULL)	{			// VERY IMPORTANT STEP//.........这里部分代码省略.........
开发者ID:DahBlount,项目名称:fs2open.github.com,代码行数:101,


示例6: used

//.........这里部分代码省略.........            pPathEnd = strchr(pPathStart, ':');            if (!pPathEnd)            {                pPathEnd = pPathStart + strlen(pPathStart);                /* we want to break out of the loop after this pass, so let                   *pNextPath be '/0' */                pNextPath = pPathEnd;            }            else            {                /* point to the next component in the path string */                pNextPath = pPathEnd+1;            }                PathLength = pPathEnd-pPathStart;                if (PathLength+FileNameLength+1 >= MAX_PATH)             {                /* The path+'/'+file length is too long.  Skip it. */                WARN("path component %.*s is too long, skipping it/n",                      (int)PathLength, pPathStart);                continue;            }            else if(0 == PathLength)            {                /* empty component : there were 2 consecutive ':' */                continue;            }                /* Construct a pathname by concatenating one path from lpPath, '/'                and lpFileName */            memcpy(FullPath, pPathStart, PathLength);            FullPath[PathLength] = '/';            if (strcpy_s(&FullPath[PathLength+1], MAX_PATH-PathLength, lpFileName) != SAFECRT_SUCCESS)            {                ERROR("strcpy_s failed!/n");                SetLastError( ERROR_FILENAME_EXCED_RANGE );                nRet = 0;                goto done;            }            /* Canonicalize the path to deal with back-to-back '/', etc. */            dw = GetFullPathNameA(FullPath, MAX_PATH,                                  CanonicalFullPath, NULL);            if (dw == 0 || dw >= MAX_PATH)             {                /* Call failed - possibly low memory.  Skip the path */                WARN("couldn't canonicalize path <%s>, error is %#x. "                     "skipping it/n", FullPath, GetLastError());                continue;            }                /* see if the file exists */            if(0 == access(CanonicalFullPath, F_OK))            {                /* found it */                nRet = dw;                break;            }        }    }    if (nRet == 0)     {       /* file not found anywhere; say so. in Windows, this always seems to say          FILE_NOT_FOUND, even if path doesn't exist */
开发者ID:nguyenm100,项目名称:coreclr,代码行数:67,


示例7: GetFullPathNameA

//.........这里部分代码省略.........    {        fullPath = TRUE;    }    if(fullPath)    {        lpUnixPath = PAL__strdup( lpFileName );        if(NULL == lpUnixPath)        {            ERROR("strdup() failed; error is %d (%s)/n",                  errno, strerror(errno));            SetLastError(ERROR_NOT_ENOUGH_MEMORY);            goto done;        }    }       else    {        size_t max_len;        /* allocate memory for full non-canonical path */        max_len = strlen(lpFileName)+1; /* 1 for the slash to append */        max_len += MAX_LONGPATH + 1;         lpUnixPath = (LPSTR)PAL_malloc(max_len);        if(NULL == lpUnixPath)        {            ERROR("PAL_malloc() failed; error is %d (%s)/n",                  errno, strerror(errno));            SetLastError(ERROR_NOT_ENOUGH_MEMORY);            goto done;        }                /* build full path */        if(!GetCurrentDirectoryA(MAX_LONGPATH + 1, lpUnixPath))        {            /* no reason for this to fail now... */            ASSERT("GetCurrentDirectoryA() failed! lasterror is %#xd/n",                   GetLastError());            SetLastError(ERROR_INTERNAL_ERROR);            goto done;        }                if (strcat_s(lpUnixPath, max_len, "/") != SAFECRT_SUCCESS)        {            ERROR("strcat_s failed!/n");            SetLastError(ERROR_FILENAME_EXCED_RANGE);            goto done;        }        if (strcat_s(lpUnixPath, max_len, lpFileName) != SAFECRT_SUCCESS)        {            ERROR("strcat_s failed!/n");            SetLastError(ERROR_FILENAME_EXCED_RANGE);            goto done;        }    }    /* do conversion to Unix path */    FILEDosToUnixPathA( lpUnixPath );     /* now we can canonicalize this */    FILECanonicalizePath(lpUnixPath);    /* at last, we can figure out how long this path is */    nReqPathLen = strlen(lpUnixPath)+1;    if(nBufferLength < nReqPathLen)    {        TRACE("reporting insufficient buffer : minimum is %d, caller "              "provided %d/n", nReqPathLen, nBufferLength);        nRet = nReqPathLen;        goto done;    }    nRet = nReqPathLen-1;    strcpy_s(lpBuffer, nBufferLength, lpUnixPath);    /* locate the filename component if caller cares */    if(lpFilePart)    {        *lpFilePart = strrchr(lpBuffer, '/');        if (*lpFilePart == NULL)        {            ASSERT("Not able to find '/' in the full path./n");            SetLastError( ERROR_INTERNAL_ERROR );            nRet = 0;            goto done;        }        else         {            (*lpFilePart)++;         }    }done:    PAL_free (lpUnixPath);    LOGEXIT("GetFullPathNameA returns DWORD %u/n", nRet);    PERF_EXIT(GetFullPathNameA);    return nRet;}
开发者ID:nguyenm100,项目名称:coreclr,代码行数:101,


示例8: strcpy_s

BOOL CDBConnect::init(){	strcpy_s(m_szConnStr, g_pCfg->GetDBConnStr().GetBuffer());	strcpy_s(m_szUser, g_pCfg->GetDBUser().GetBuffer());	strcpy_s(m_szPwd, g_pCfg->GetDBPwd());	try	{		//没有配置oracle客户端情况下ado连接字符串		//CString  m_sConn="Provider=OraOLEDB.Oracle.1;Password=platform1234;Persist Security Info=True;User ID=platform;Data Source=/"(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 服务器地址)(PORT = 1521)) )(CONNECT_DATA = (SID = 数据库实例名)))/"";				//配置好了oracle客户端 情况下ado连接字符串		CString m_sConn;		m_sConn.Format("Provider=OraOLEDB.Oracle.1;Persist Security Info=True;server=serveraddress;Data Source=%s;User ID=%s;Password=%s",			m_szConnStr, m_szUser, m_szPwd);				m_pConnection->Open((_bstr_t)m_sConn,"","",adConnectUnspecified);				//下面是查询数据的例子		CString strSql = "update authentication set auth_info = '2EXR8U3TUWYUOWF167PT4W46I4R550H1' where user_code = 9999";		//CString strSql = "select authentication.auth_info from authentication where authentication.user_code = 9999";		BSTR bstrSQL = strSql.AllocSysString();		_variant_t RecordsAffected; //VARIANT数据类型		m_pConnection->BeginTrans();		m_pConnection->Execute(bstrSQL,&RecordsAffected,adCmdText);		m_pConnection->CommitTrans();		strSql="select * from  customers where cust_code = 10007887";		bstrSQL = strSql.AllocSysString();		m_pRecordset->Open(bstrSQL, (IDispatch*)m_pConnection, adOpenDynamic, adLockOptimistic, adCmdText); 				_variant_t TheValue; //VARIANT数据类型		char szTmp[100] = {0};		while(!m_pRecordset->adoEOF)		{							TheValue = m_pRecordset->GetCollect("CUST_CODE");			if(TheValue.vt!=VT_NULL)			{								strncpy_s(szTmp, (char*)_bstr_t(TheValue), 100);			}			m_pRecordset->MoveNext();		}		m_pRecordset->Close();	}	catch (_com_error e)//异常处理	{		CString strMsg;		strMsg.Format(_T("错误描述:%s/n错误消息%s"),		(LPCTSTR)e.Description(),		(LPCTSTR)e.ErrorMessage());		return FALSE;	}	g_pLog->WriteRunLog(SYS_MODE, LOG_DEBUG, "初始化DBConn成功! ConnStr:%s, User:%s, Pwd:%s", m_szConnStr, m_szUser, m_szPwd);	return TRUE;}
开发者ID:firememory,项目名称:iRobot,代码行数:61,


示例9: scr_label

//.........这里部分代码省略.........            cc = getarg();            if( cc == pos ) {           // label name specefied                char    *   p;                char    *   pt;                int         len;                p   = tok_start;                pt  = token_buf;                len = 0;                while( len < arg_flen ) {   // copy to buffer                    *pt++ = *p++;                    len++;                }                *pt = '/0';                if( len >  MAC_NAME_LENGTH ) {                    err_count++;                    g_err( err_sym_long, token_buf );                    ultoa( input_cbs->s.f->lineno, linestr, 10 );                    g_info( inf_file_line, linestr, input_cbs->s.f->filename );                    show_include_stack();                    token_buf[MAC_NAME_LENGTH] = '/0';                }                if( input_cbs->fmflags & II_macro ) {                    cc = test_duplicate( token_buf, input_cbs->s.m->lineno );                    if( cc == pos ) {   // ok name and lineno match                        // nothing to do                    } else {                        if( cc == neg ) {   // name with different lineno                            scan_err = true;                            err_count++;                            g_err( err_label_dup, token_buf );                            ultoa( input_cbs->s.m->lineno, linestr, 10 );                            g_info( inf_mac_line, linestr,                                     input_cbs->s.m->mac->name );                            show_include_stack();                            return;                        } else {        // new label                            lb              = mem_alloc( sizeof( labelcb ) );                            lb->prev        = input_cbs->s.m->mac->label_cb;                            input_cbs->s.m->mac->label_cb = lb;                            lb->pos         = 0;                            lb->lineno      = input_cbs->s.m->lineno;                            strcpy_s( lb->label_name, sizeof( lb->label_name ),                                      token_buf );                        }                    }                } else {                    cc = test_duplicate( token_buf, input_cbs->s.f->lineno );                    if( cc == pos ) {   // ok name and lineno match                        // nothing to do                    } else {                        if( cc == neg ) {   // name with different lineno                            scan_err = true;                            err_count++;                            g_err( err_label_dup, token_buf );                            ultoa( input_cbs->s.f->lineno, linestr, 10 );                            g_info( inf_file_line, linestr, input_cbs->s.f->filename );                            show_include_stack();                            return;                        } else {        // new label                            lb              = mem_alloc( sizeof( labelcb ) );                            lb->prev        = input_cbs->s.f->label_cb;                            input_cbs->s.f->label_cb = lb;                            lb->pos         = input_cbs->s.f->pos;                            lb->lineno      = input_cbs->s.f->lineno;                            strcpy_s( lb->label_name, sizeof( lb->label_name ),                                      token_buf );                        }                    }                }            } else {                scan_err = true;                err_count++;                g_err( err_missing_name, "" );                if( input_cbs->fmflags & II_macro ) {                    ultoa( input_cbs->s.m->lineno, linestr, 10 );                    g_info( inf_mac_line, linestr, input_cbs->s.m->mac->name );                } else {                    ultoa( input_cbs->s.f->lineno, linestr, 10 );                    g_info( inf_file_line, linestr, input_cbs->s.f->filename );                }                show_include_stack();                return;            }        }        if( *scan_start == ' ' ) {            scan_start++;               // skip one blank            if( *scan_start ) {         // rest of line is not empty                split_input( buff2, scan_start, false );// split and process next            }        }        scan_restart = scan_stop + 1;        return;    }}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:101,


示例10: ConsoleCommand

void ConsoleCommand(){	char command[127];	char args[4][127];	int tmp;	FILE *file_exist;	Help();	while(true)	{	 printf("> ");	 gets_s(command);	 sscanf(command, "%s %s", args[0], args[1]);	 if(!strcmp(args[0], "load"))	 {	  printf("COMMAND LOADING [%s]/n", args[1]);	  for(int i = 0; i < MAX_SCRIPT_RUN; i++)	  {		if(LS[i].active == false)		{		 strncpy_s(PATH_FILE_TMP_FILE, PATH_FILE, index_file+1);		 PATH_FILE_TMP_FILE[index_file+1] = '/0';      		 strcat_s(PATH_FILE_TMP_FILE,  args[1]);		 strcpy_s(LS[i].FileScrips, PATH_FILE_TMP_FILE);		 if(file_exist = fopen(LS[i].FileScrips, "r"))		 {		  loadscript(L, LS[i].FileScrips);		  LS[i].active = true;		  scrips_load++;		  printf("SCRIPT_ID [%d]/n", i);		  printf("[%d] Script Loaded/n", scrips_load);		  fclose(file_exist);		 }		 else		 {		  printf("ERROR: file no found/n");		  LS[i].FileScrips[0] = NULL;		 }		 break;		}	  }	 }	 if(!strcmp(args[0], "stop"))	 {	  tmp = atol(args[1]);	  if(LS[tmp].FileScrips[0] != NULL)	  {	   LS[tmp].active = false;	   printf("STOP SUCESSFULLY/n");	  }	  else	   printf("STOP FAILED/n");	 }	 if(!strcmp(args[0], "start"))	 {	  tmp = atol(args[1]);	  if(LS[tmp].FileScrips[0] != NULL)	  {	   LS[tmp].active = true;	   printf("START SUCESSFULLY/n");	  }	  else	   printf("START FAILED/n");	 }	 if(!strcmp(args[0], "exit"))	  exit(1);	 args[0][0] = NULL;	 args[1][0] = NULL;	 args[2][0] = NULL;	 args[3][0] = NULL;	}}
开发者ID:Areidz,项目名称:BotScript,代码行数:81,


示例11: display

//.........这里部分代码省略.........		vx -= 0.001 * pow(t, 4);		vy -= 0.002 * pow(t, 4);	}	/* シュ
C++ strcpyn函数代码示例
C++ strcpy_P函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。