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

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

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

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

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

示例1: NiashLibUsbInit

void NiashLibUsbInit(TFnReportDevice* const pfnReportDevice){	class HDEVINFODeleter //RAII wrapper	{	public:		typedef HDEVINFO pointer;		void operator()(HDEVINFO h) {::SetupDiDestroyDeviceInfoList(h);}	};	//Get device	std::unique_ptr<HDEVINFO, HDEVINFODeleter> hDevInfo(SetupDiGetClassDevs(&s_NiashInterfaceClassGUID, NULL, NULL, DIGCF_PRESENT|DIGCF_PROFILE|DIGCF_DEVICEINTERFACE));	if(hDevInfo.get() == INVALID_HANDLE_VALUE)	{		wprintf_s(L"SetupDiGetClassDevs: %s/n", _com_error(GetLastError()).ErrorMessage());		return;	}		//Get device info for the devices	SP_DEVINFO_DATA DeviceInfoData;	DeviceInfoData.cbSize = sizeof(DeviceInfoData);	SetupDiEnumDeviceInfo(hDevInfo.get(),0,&DeviceInfoData);	if(GetLastError()==ERROR_NO_MORE_ITEMS)	{		puts("No devices with the driver installed found.");	}	else	{		wprintf_s(L"SetupDiEnumDeviceInfo: %s/n", _com_error(GetLastError()).ErrorMessage());	}	//Get the first matching device interface of that device	SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;	DeviceInterfaceData.cbSize = sizeof(DeviceInterfaceData);		if(!SetupDiEnumDeviceInterfaces(hDevInfo.get(), &DeviceInfoData, &s_NiashInterfaceClassGUID, 0, &DeviceInterfaceData))	{		wprintf_s(L"SetupDiEnumDeviceInterfaces: %s/n", _com_error(GetLastError()).ErrorMessage());		return;	}	//Get size of detailed device interface data	DWORD dwRequiredSize;	if(!SetupDiGetDeviceInterfaceDetail(hDevInfo.get(), &DeviceInterfaceData, nullptr, 0, &dwRequiredSize, nullptr) && GetLastError() != ERROR_INSUFFICIENT_BUFFER)	{		wprintf_s(L"SetupDiGetDeviceInterfaceDetail: %s/n", _com_error(GetLastError()).ErrorMessage());		return;	}	//SP_DEVICE_INTERFACE_DETAIL_DATA's actual size isn't declared	std::unique_ptr<SP_DEVICE_INTERFACE_DETAIL_DATA_A> pInterfaceDetailData(reinterpret_cast<SP_DEVICE_INTERFACE_DETAIL_DATA_A*>(new BYTE[dwRequiredSize]));	pInterfaceDetailData->cbSize = sizeof(*pInterfaceDetailData);	if(!SetupDiGetDeviceInterfaceDetailA(hDevInfo.get(), &DeviceInterfaceData, pInterfaceDetailData.get(), dwRequiredSize, nullptr, nullptr))	{		wprintf_s(L"SetupDiGetDeviceInterfaceDetail: %s/n", _com_error(GetLastError()).ErrorMessage());		return;	}	//Get name size	ULONG ulPropType = DEVPROP_TYPE_STRING;	if(!SetupDiGetDeviceProperty(hDevInfo.get(), &DeviceInfoData, &DEVPKEY_NAME, &ulPropType, nullptr, 0, &dwRequiredSize, 0) && GetLastError() != ERROR_INSUFFICIENT_BUFFER)	{		wprintf_s(L"SetupDiGetDeviceProperty: %s/n", _com_error(GetLastError()).ErrorMessage());		return;	}	//Get device name	std::vector<TCHAR> Buf(dwRequiredSize);	if(!SetupDiGetDeviceProperty(hDevInfo.get(), &DeviceInfoData, &DEVPKEY_NAME, &ulPropType, reinterpret_cast<PBYTE>(Buf.data()), dwRequiredSize, 0, 0))	{		wprintf_s(L"SetupDiGetDeviceProperty: %s/n", _com_error(GetLastError()).ErrorMessage());		return;	}	wprintf_s(L"Found device: %s ", Buf.data());	printf_s("%s/n", pInterfaceDetailData->DevicePath);	//Let driver recognize the device so it knows what parameters to use	int vid = 0;	int pid = 0;	if(sscanf_s(pInterfaceDetailData->DevicePath,"////?//usb#vid_%x&pid_%x#", &vid, &pid) == 2 && MatchUsbDevice(vid,pid,&s_pScannerModel))	{		pfnReportDevice(s_pScannerModel, pInterfaceDetailData->DevicePath);	}}
开发者ID:mkentie,项目名称:3300c,代码行数:82,


示例2: PolyLineStart

bool CDxfRead::ReadLwPolyLine(bool undoably){	PolyLineStart();	bool x_found = false;	bool y_found = false;	double x = 0.0;	double y = 0.0;	bool bulge_found = false;	double bulge = 0.0;	bool closed = false;	int flags;	bool next_item_found = false;	while(!((*m_ifs).eof()) && !next_item_found)	{		get_line();		int n;		if(sscanf_s(m_str, "%d", &n) != 1)return false;		std::istringstream ss;		ss.imbue(std::locale("C"));		switch(n){			case 0:				// next item found				if(x_found && y_found){					// add point					AddPolyLinePoint(this, x, y, bulge_found, bulge, undoably);					bulge_found = false;					x_found = false;					y_found = false;				}				next_item_found = true;				break;			case 10:				// x				get_line();				if(x_found && y_found){					// add point					AddPolyLinePoint(this, x, y, bulge_found, bulge, undoably);					bulge_found = false;					x_found = false;					y_found = false;				}				ss.str(m_str); ss >> x; if(ss.fail()) return false;				x_found = true;				break;			case 20:				// y				get_line();				ss.str(m_str); ss >> y; if(ss.fail()) return false;				y_found = true;				break;			case 42:				// bulge				get_line();				ss.str(m_str); ss >> bulge; if(ss.fail()) return false;				bulge_found = true;				break;			case 70:				// flags				get_line();				if(sscanf_s(m_str, "%d", &flags) != 1)return false;				closed = ((flags & 1) != 0);				break;			default:				// skip the next line				get_line();				break;		}	}	if(next_item_found)	{		if(closed && poly_first_found)		{			// repeat the first point			AddPolyLinePoint(this, poly_first_x, poly_first_y, false, 0.0, undoably);		}		return true;	}	return false;}
开发者ID:Ychuan1115,项目名称:libarea,代码行数:83,


示例3: PlaceActor

bool PlaceActor(NxVec3 position, NxVec3 velocity, unsigned int actind)/*	This function is an intermediate step between CreateInitialPile that defines that initial positions	and velocities of each actor in the pile, and the actor creation routine, which may be simply the	familiar CreateRubbleGrain if actors should have a generic (or random) shape, or the more specialized	CreateSpecificActor, that reads the shape information from a shapes file. The branching is decided	simply by looking for the existence of a shapes file. EDIT: a shape file for non-uniform spheres is now	implemented, as is a mixed polyhedra-non-uniform-sphere file. Branching determined by the section	separator: SPHERE or SHAPE. EDIT: this function should not be called except by CreateInitialPile.*/{	bool success=false;	static bool skipSHFile=false;	// attempt to open a shapes file	char shfile[255];	sprintf(shfile,"%s//%s//%s.sh",_getcwd(NULL,0),gRunBaseName,gRunBaseName);	static ifstream fp(shfile);	if (fp.fail() || skipSHFile) {// the easy default path. creating actors based on grain_type form ini file.		NxActor* actor=CreateRubbleGrain(position);		if (actor) actor->setLinearVelocity(velocity);		if (actor) success=true;	}	else // this is the more complex path. read shapes from the shapes file.	{		// sigh. ok, here we go. the .sh file remains open so we just need to skip the header once:		static char line[255];		if (actind==0){			while (fp.good()){				fp.getline(line,255);				if (strcmp(line,"SHAPE")==0 || strcmp(line,"SPHERE")==0) break;			}			if (fp.eof()) {cout<<"ERROR:shape segments not found in shape file."<<endl; fp.close(); skipSHFile=true; return false;}		}		// otherwise, we should be in position to start reading vertex info.		if (strcmp(line,"SHAPE")==0)		{			float xx,yy,zz;			NxVec3 vertex;			vector<NxVec3> verts;			while (fp.good())			{				fp.getline(line,255);				if (strcmp(line,"/0")==0) continue; //skip empty lines. (but lines with nothing but ws are a problem.)				if (strcmp(line,"SHAPE")==0 || strcmp(line,"SPHERE")==0 || fp.eof()) break;				if (sscanf_s(line,"%f%f%f",&xx,&yy,&zz)<3) {cout<<"ERROR:bad format in shapes file."<<endl; fp.close(); return false;}				vertex.x=xx; vertex.y=yy; vertex.z=zz;				verts.push_back(vertex);			}			if (fp.eof() && actind<(RUBBLE_SIZE-1)){				cout<<"WARNING:not enough shapes in shape file. additional shapes determined by grain_type"<<endl;				fp.close();				skipSHFile=true;			}			// well well. i do believe we have extracted the vertex information for shape actind. now what?			NxActor* actor=CreateSpecificConvexShape(position,gDefaultDensity,verts); // someone else's problem now.			if (actor){				actor->setLinearVelocity(velocity);				success=true;			}		}		else if (strcmp(line,"SPHERE")==0)		{			float rr;			fp.getline(line,255);			if (sscanf_s(line,"%f",&rr)<1) {cout<<"ERROR:bad format in shapes file."<<endl; fp.close(); return false;}			while (fp.good())			{				fp.getline(line,255);				if (strcmp(line,"/0")==0) continue; //skip empty lines. (but lines with nothing but ws are a problem.)				if (strcmp(line,"SHAPE")==0 || strcmp(line,"SPHERE")==0 || fp.eof()) break;				cout<<"ERROR:bad format in shapes file."<<endl; fp.close(); return false;			}			if (fp.eof() && actind<(RUBBLE_SIZE-1)){				cout<<"WARNING:not enough shapes in shape file. additional shapes determined by grain_type"<<endl;				fp.close();				skipSHFile=true;			}			NxActor* actor=CreateSphericalGrain(position,gDefaultDensity,rr*2);			if (actor){				actor->setLinearVelocity(velocity);				success=true;			}		}		else		{			cout<<"WARNING:unknown *shape* in shapes file. additional shapes determined by grain_type"<<endl;			fp.close();			skipSHFile=true;		}	}	// done.	return success;}
开发者ID:nmovshov,项目名称:ARSS_win,代码行数:96,


示例4: while

bool CDxfRead::ReadLine(bool undoably){	double s[3] = {0, 0, 0};	double e[3] = {0, 0, 0};	while(!((*m_ifs).eof()))	{		get_line();		int n;		if(sscanf_s(m_str, "%d", &n) != 1)return false;		std::istringstream ss;		ss.imbue(std::locale("C"));		switch(n){			case 0:				// next item found, so finish with line				OnReadLine(s, e, undoably);				return true;			case 10:				// start x				get_line();				ss.str(m_str); ss >> s[0]; if(ss.fail()) return false;				break;			case 20:				// start y				get_line();				ss.str(m_str); ss >> s[1]; if(ss.fail()) return false;				break;			case 30:				// start z				get_line();				ss.str(m_str); ss >> s[2]; if(ss.fail()) return false;				break;			case 11:				// end x				get_line();				ss.str(m_str); ss >> e[0]; if(ss.fail()) return false;				break;			case 21:				// end y				get_line();				ss.str(m_str); ss >> e[1]; if(ss.fail()) return false;				break;			case 31:				// end z				get_line();				ss.str(m_str); ss >> e[2]; if(ss.fail()) return false;				break;			case 100:			case 39:			case 210:			case 220:			case 230:				// skip the next line				get_line();				break;			default:				// skip the next line				get_line();				break;		}	}	OnReadLine(s, e, undoably);	return false;}
开发者ID:Ychuan1115,项目名称:libarea,代码行数:66,


示例5: nCreateMultipleHardwareNetwork

/*** /brief         This function will get the hardware selection from the user*                and will create essential networks.* /param         unDefaultChannelCnt* /return        returns defERR_OK (always)* /authors       [email
C++ ssd1306_command函数代码示例
C++ sscanf_P函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。