ifstream infile;
string read_file_name("test.txt");
infile.open(read_file_name);
string sLine;
while (!infile.eof())
{
getline(infile, sLine);
cout << sLine.data() << endl;
}
infile.close();
Run Code Online (Sandbox Code Playgroud)
该程序打印文件中的所有行,但我想只打印第一行.
这是我的代码.
#include <iostream>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include <cmath>
#include <functional>
using namespace std;
void main()
{
cout<<log2(3.0)<<endl;
}
Run Code Online (Sandbox Code Playgroud)
但上面的代码给出了错误.错误代码是:错误C3861:'log2':找不到标识符.如何使用c ++计算log2?
我有两个向量
int main(int argc, char *argv())
{
.........
Vector3f center(0.4,0.1,0.3) ;
Vector3f point(0.1,0.2,0.7);
.......
}
Run Code Online (Sandbox Code Playgroud)
如何使用特征库计算曼哈顿距离?我正在使用VS2010.
有没有像Boost,Eigen,OpenCV这样可以计算回忆和精度的c ++库?
我有一个文本文件,如下面的read.txt:
1.0 2.0 3.0 4.0
2.0 3.0 4.0 6
5.0 7 1.0 5.0
Run Code Online (Sandbox Code Playgroud)
calc.cpp:
void main()
{
FILE *fp;
fp=fopen("read.txt","r");
double *read_feature = new double*[3];
for(i = 0; i<3; i++)
read_feature[i] = new double[3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
fscanf(fp,"%lf",&read_feature[i][j]);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想计算我的文本文件中的所有数字(read.txt).读取文本文件由浮点数和整数组成.上述文件的答案是12.
如何动态地使用c ++计算文件中的浮点数?这意味着不给出i和j的值.我需要程序会自动计算i和j的总数.