当前位置: 首页>>代码示例>>C++>>正文


C++ string::close方法代码示例

本文整理汇总了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;
}
开发者ID:kernl,项目名称:Multi-GPU_Saxpy,代码行数:21,代码来源:main.cpp

示例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();
}
开发者ID:austinwillis,项目名称:graphics,代码行数:36,代码来源:draw.cpp


注:本文中的std::string::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。