ifstream

    0热度

    3回答

    我想让行标记//此行应该打印做它的事情,这是打印“同义词”和“反义词”之间的int值。 这是文本文件: dictionary.txt 1 cute 2 hello 3 ugly 4 easy 5 difficult 6 tired 7 beautiful synonyms 1 7 7 1 antonyms 1 3 3 1 7 4 5 5 4 7 3 #i

    -2热度

    1回答

    我想消除我在下面的vector<int> synsAux上遇到的垃圾。它应该打印: 1 7 7 1 我的第一和第三位,为什么之前获得一个额外的2?这是2的空格或什么的ascii值?我如何避免阅读? 这是运行程序所需要的字典文件: dictionary.txt 1 cute 2 hello 3 ugly 4 easy 5 difficult 6 tired 7 beautif

    7热度

    5回答

    我一直在这里关于ifstream的问题,所以我仍然无法阅读简单的文本文件。我与Visual Studio 2008年的工作 这里是我的代码: // CPPFileIO.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <fstream> #include <

    3热度

    1回答

    说我这样做(一个人为的例子): #include <iostream> #include <fstream> using namespace std; int main(int argc, char* argv[]) { ifstream ifs(argv[1]); char ch; while(ifs.read(&ch, 1)) { cou

    1热度

    3回答

    当出现单词“同义词”时,我想停止阅读我的文本输入文件。我正在使用ifstream,我不知道如何打破循环。我尝试使用stringstream“同义词”,但它结束了我的bst。如果您想避免打字,我会在下面列出完整的项目文件。 重要组成部分: for(;;) /*here, I wanna break the cycle when it reads "synonyms"*/ {

    0热度

    3回答

    我知道关于std :: ifstream :: open()有一些问题,但答案并没有解决我的问题。他们大多数都是特定于Win32的,我使用的是SDL,没有触及任何特定于操作系统的功能(......没有包含到SDL中)。 问题是:std :: ifstream :: open()似乎不工作了,因为我已经从Dev-C++切换到Code :: Blocks(我一直在使用相同的MinGW-GCC返回与两者

    1热度

    1回答

    在VS 2005,我有一些代码,看起来像这样: ifs.open("foo"); while (!ifs.eof()) { ifs.read(&bar,sizeof(bar)); loc = ifs.tellg(); loc += bar.dwHeaderSize; // four byte boundary padding if ((loc

    6热度

    5回答

    我目前正在编写一个模拟退火代码来解决旅行商问题,并遇到了存储和使用从txt文件中读取数据的困难。文件中的每一行&列表示各城市,存储为15×15矩阵的两个不同城市之间的距离: 0.0 5.0 5.0 6.0 7.0 2.0 5.0 2.0 1.0 5.0 5.0 1.0 2.0 7.1 5.0 5.0 0.0 5.0 5.0 5.0 2.0 5.0 1.0 5.0 6.0 6.0 6.0 6.0

    8热度

    3回答

    我想从二进制文件中读取无符号字节。 所以我写了下面的代码。 #include <iostream> #include <fstream> #include <vector> #include <istream> std::string filename("file"); size_t bytesAvailable = 128; size_t toRead = 128; std::