在VS11创建的Metro应用程序中,我在哪里可以找到主要功能?
我知道这听起来很傻但我试图寻找它并且无法在任何地方找到它.
请告诉我这里我做错了什么.我想要做的是:
1.有四个数字的txt文件,每个数字有15位数:
std::ifstream file("numbers.txt",std::ios::binary);
Run Code Online (Sandbox Code Playgroud)
我正在尝试将这些数字读入我的数组:
char num[4][15];
Run Code Online (Sandbox Code Playgroud)
而我正在想的是:只要你没有到达文件的末尾就会将每一行(最多15个字符,以'\n'结尾)写入num [lines].但这有点不起作用.首先它只读取第一个数字,rest只是""(空字符串),其次file.eof()似乎也无法正常工作.在我在下面这段代码中提出的txt文件中,我达到了等于156的行.发生了什么事?
for (unsigned lines = 0; !file.eof(); ++lines)
{
file.getline(num[lines],15,'\n');
}
Run Code Online (Sandbox Code Playgroud)
所以整个"例程"看起来像这样:
int main()
{
std::ifstream file("numbers.txt",std::ios::binary);
char numbers[4][15];
for (unsigned lines = 0; !file.eof(); ++lines)
{
file.getline(numbers[lines],15,'\n');// sizeof(numbers[0])
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的txt文件的内容:
111111111111111
222222222222222
333333333333333
444444444444444
PS
我正在使用VS2010 sp1
我有一个非常漂亮的get fnc,它返回指向'a type'的指针.现在我想在fnc set中重用这个fnc来为get返回的这个类型设置一些值:
template<class Tag,class Type>
set(Type t, some_value)
{
get<Tag>(t) = value;
}
Run Code Online (Sandbox Code Playgroud)
我唯一的问题是:因为get返回指针而不是对指针的引用,所以返回类型是一个rvalue,对于大多数情况来说很好但不适用于此.有没有办法以某种方式将返回值更改为左值?
是否有任何理由在StreamWriter类上调用close方法?我为什么要这样做?如果我不关闭StreamWriter,我会得到某种未定义的行为吗?
此代码正确获取selected_paths中指定的目录的内容,但前提是该目录为"C:".如果目录是"D:",则此代码将迭代我的应用程序的根目录(源文件所在的目录 - "D:\ excercizes\QT_projects\my_app").这是怎么回事?
QStringList my_app::extract_files_from_paths_(const QStringList& selected_paths)const
{
boost::filesystem3::path path;
QStringList result;
for (auto e : selected_paths)
{
boost::filesystem3::path path(e.toStdString().c_str());
if (boost::filesystem3::is_regular_file(path))
{
result.append(e);
}
else if (boost::filesystem3::is_directory(path) && !boost::filesystem3::is_empty(path))
{
std::vector<boost::filesystem3::path> paths_;
/*add everything from this path*/
std::copy(boost::filesystem3::directory_iterator(path), boost::filesystem3::directory_iterator(), // directory_iterator::value_type
std::back_inserter(paths_));
QStringList list_of_files;
for(auto e : paths_)
{
list_of_files.append(QString(e.string().c_str()));
}
return extract_files_from_paths_(list_of_files);
}
}
return result;
}
Run Code Online (Sandbox Code Playgroud) 我是一位非常正式的导师,坚持超级正确地使用术语.在我的任务中,我将Qt :: Thread称为一个库,并且他标记了我说它不是库而是一个类.现在我很困惑,不得不问这里,它只是一个班级还是一个图书馆?
正在读一个bool原子动作?
if (value != true)//here I'm reading bool, then I'm comparing it to the value I'm interested in.
Run Code Online (Sandbox Code Playgroud)
另外,读取它需要多少个处理器周期?