本文整理汇总了C++中std::string::close方法的典型用法代码示例。如果您正苦于以下问题:C++ string::close方法的具体用法?C++ string::close怎么用?C++ string::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::string
的用法示例。
在下文中一共展示了string::close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: programFromSource
// This auxiliary function has been adapted from work done by Ricardo Marques
// in the context of his thesis.
cl_program programFromSource(const std::string &fileName, const cl_context context){
std::ifstream kernelFile(fileName.data(), std::ios::in);
if (!kernelFile.is_open()){
kernelFile.close();
throw;
}
int errcode;
cl_program program;
std::ostringstream oss;
oss << kernelFile.rdbuf();
std::string srcStdStr = oss.str();
const char *srcStr = srcStdStr.c_str();
program = clCreateProgramWithSource(context, 1, (const char**)&srcStr, NULL, &errcode);
if(errcode != CL_SUCCESS){
std::cerr << errorString(errcode) << std::endl;
return NULL;
}
return program;
}
示例2: readFile
void readFile(char * filename) {
string line;
cout << "opening " << filename << endl;
ifstream file(filename);
if (file == NULL) {
cout << "Could not open file" << endl;
exit (EXIT_FAILURE);
}
double x, y, x2, y2;
file >> x;
file >> y;
file >> x2;
file >> y2;
screenWidth = x2;
screenHeight = y;
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 150);
glutCreateWindow("Drawing");
stringstream ss;
file >> x;
for (int i = 0; i < x; i++) {
vector<point> points;
file >> y;
for (int j = 0; j < y; j++) {
point p;
file >> x2;
file >> y2;
p.x = x2;
p.y = y2;
points.push_back(p);
}
cors.push_back(points);
}
file.close();
}