首页 文章
  • 0 votes
     answers
     views

    ifstream寻求错误

    从结果: --0 0 --1 2 --2 20 --3 0 BONJOUR MA BICHETTE --4 -1 is_open --5 -1 --6 -1 7 20 8 0 该 ------- C CODE---------- ++1 0 ++2 20 ++3 0 ->BONJOUR MA BICHETTE feof encountered ++4 20 ++5 0 Program ...
  • 21 votes
     answers
     views

    fstream seekg(),seekp()和write()

    我正在寻找关于 seekg() 和 seekp() 如何处理文件时的一些说明 . 比方说我有一个像这样的文件: offset 0: 2 offset 4: 4 offset 8: 6 offset 12: 8 offset 16: 10 现在我想打开文件并尝试读取和写入值 . fstream file; file.open("file.txt", fstream::in |f...
  • 1 votes
     answers
     views

    从fstream读取后,如何将curor设置回预读位置?

    我正在修改 binary data 的阅读程序 . 不幸的是,我不再是C中的那个公司了,这是编写例程的语言 . 例程开始读取一些数据 . 之后,我想要它 look at a buffered value ,我也从文件中读取 . Depending on the value 代码应该执行某些操作并在之后正常继续 or undo reading the buffer 并继续正常运行 . 我的问题是...
  • -1 votes
     answers
     views

    如果不存在利用seekp / seekg,使用fstream创建文件?

    fstream file(file_1.c_str(), ios::out | ios::in | ios::ate); //convert string to const char* 如果文件不存在则出错 . if ( ! file ) = true fstream file(file_1.c_str(), ios::out | ios::in | ios::app); //convert...
  • 1 votes
     answers
     views

    ifstream :: seekg给出了错误的结果

    我正在玩ifstream来熟悉它 . 我试图使用seekg来告诉文件的位置,但它给了我错误的结果 . 这个想法是: 打开文件 文件的打印位置 从文件中读取一个字符 文件的打印位置 从文件中读取一个字符 文件的打印位置 关闭文件 . 原始文件看起来像这样(Windows格式): file.txt aA bB cC dD eE fF 运行我的代码,我得到结果: pos...

热门问题