[personal profile] palindromer

Иногда Ctrl-Ins, Shift-Ins экономит секунды и отнимает минуты (хорошо если не часы)

#include < fstream >
#include < string >

using namespace std;

int main()
{
   {
      ofstream ofs("test.txt");
      if(ofs)
         ofs << string("test");
    }

    string str;

    {
	ifstream ifs("test.txt");
	if(ifs)
	{
	    ifs >> string(str);
	    _ASSERT(str == string("test"));
	}
    }
    return 0;
}


На похожих граблях танцевал сегодня минут десять, пока намыленный взгляд не споткнулся таки о нужную строчку.

Date: 2009-01-12 01:45 pm (UTC)
From: [identity profile] comargo.livejournal.com
ifs >> string(str); --- это и есть та самая грабля?

Date: 2009-01-12 02:04 pm (UTC)