2020-11-13

这一天努努妈做了什么


1. 要将大型数据集下载到linux服务器上,不用从本地上传,直接通过网址在线下载

对于大型文件 使用-c命令 可以从上次中断的地方开始下载

其他命令见  https://www.jianshu.com/p/5c4e2280f714  (我还不会插入链接


2.#include<boost/assert.hpp>

#include<boost/program_options.hpp>

assert用法?

打开文件步骤中有一句 assert(NULL != fip);


3. 为什么经常出现string无法定义的情况呢

C++中,头文件为#include<string>,而非#include<string.h>

cstring、string和string.h的区别https://www.cnblogs.com/Cmpl/archive/2012/01/01/2309710.html

strcpy是c语言中的函数 如果用了string头文件就不能这样调用了

https://sunlogging.blog.csdn.net/article/details/20242307?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.edu_weight

这里说的其实有问题,string并没有包括string.h的所有操作,比如strcpy就不行

<cstring>是与C标准库的<string.h>相对应,但裹有std名字空间的版本。

要想既可以定义string s又能够使用strcmp strcpy等函数,写法如下:

#include < string .h > #include < string > using namespace std;

或者

#include < cstring > #include < string >

插播一条评论:#include <iostream> //已经包含了string类型的标准类,所以定义string类型时候没有对应头文件的申明也不会报错  


4. linux和windows下读取写入文件的操作是不是有不一样?没有‘

main(int argc, char *argv[])  {

    string input_path;   string output_path;

    input_path = argv[0];   output_path = argv[1];

FILE* fip = fopen(input_path,"rb");   FILE* fop = fopen(output_path,"wb");

报错:[Error] cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'FILE* fopen(const char*, const char*)'

FILE* fip = fopen(argv[0],"rb"); //正确

方法一:(论文源码)

iostream类的子类fstream,专门用来处理文件读写。

打开用open,也可以直接在定义的时候打开

关闭用close

https://www.cnblogs.com/batman425/p/3179520.html

fstream file1;  file1.open("c:\\config.sys",ios::binary|ios::in,0);

fstream file1("c:\\config.sys");

特别地,fstream有两个子类:

ifstream(input file stream)和ofstream(outpu file stream),

ifstream默认以输入方式打开文件

ofstream默认以输出方式打开文件。 可以直接挑选使用

成员函数read、write用于数据块的读写

C++的文件定位分为读位置和写位置的定位,对应的成员函数是seekg()和seekp()。

其他方法:https://blog.csdn.net/nichengwuxiao/article/details/78789225

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。