1>项目:错误PRJ0003:错误产生'rc.exe'..这是我在尝试运行这个读取和写入文件的小练习程序时得到的错误,因为我无法做到这一点让文件正确打开.我使用microsoft visual c ++ 2008,我已经使用文件路径尝试打开文件,我不能有人帮忙吗?
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
ifstream infile;
ofstream myfile;
int num;
infile.open("example.txt");
if(infile.fail())
{
cout << "error" << endl;
}
myfile.open ("example.txt");
if(infile.fail())
{
cout << "error" << endl;
}
while(!infile.eof())
{
example >> num;
}
while(!myfile.eof())
{
example << num;
}
infile.close();
myfile.close();
return 0;
}
Run Code Online (Sandbox Code Playgroud) int exam1[100];// array that can hold 100 numbers for 1st column
int exam2[100];// array that can hold 100 numbers for 2nd column
int exam3[100];// array that can hold 100 numbers for 3rd column
int main()
{
ifstream infile;
int num;
infile.open("example.txt");// file containing numbers in 3 columns
if(infile.fail()) // checks to see if file opended
{
cout << "error" << endl;
}
while(!infile.eof()) // reads file to end of line
{
for(i=0;i<100;i++); // array numbers less than 100
{
while(infile …Run Code Online (Sandbox Code Playgroud) 有人也可以告诉我,我试图做的行动是否正确.我是c ++的新手,我认为它是正确的,但我有疑问
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<iomanip>
using namespace std;
int main()
{
ifstream in_stream; // reads itemlist.txt
ofstream out_stream1; // writes in items.txt
ifstream in_stream2; // reads pricelist.txt
ofstream out_stream3;// writes in plist.txt
ifstream in_stream4;// read recipt.txt
ofstream out_stream5;// write display.txt
float price=' ',curr_total=0.0;
int wrong=0;
int itemnum=' ';
char next;
in_stream.open("ITEMLIST.txt", ios::in); // list of avaliable items
if( in_stream.fail() )// check to see if itemlist.txt is open
{
wrong++;
cout << " the error occured here0, you have " …Run Code Online (Sandbox Code Playgroud) 这个程序运行但不正确的数字不对,我从文件中读取数字,然后当我在程序中使用它们时他们是不对的.:我正在尝试做的解释可以有人告诉我,如果看起来不对.
这就是我要做的:
编写一个程序,确定100名学生的成绩分散
您要将考试成绩读入三个阵列,每个考试一个阵列.然后你必须计算得分A(90或以上),B(80或以上),C(70或以上),D(60或以上)和F(少于60)的得分数.为每个考试执行此操作并将分发写入屏幕.
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int read_file_in_array(double exam[100][3]);
double calculate_total(double exam1[], double exam2[], double exam3[]); // function that calcualates grades to see how many 90,80,70,60
//void display_totals();
double exam[100][3];
int main()
{
double go,go2,go3;
double exam[100][3],exam1[100],exam2[100],exam3[100];
go=read_file_in_array(exam);
go2=calculate_total(exam1,exam2,exam3);
//go3=display_totals();
cout << go,go2,go3;
return 0;
}
/*
int display_totals()
{
int grade_total;
grade_total=calculate_total(exam1,exam2,exam3);
return 0;
} */
double calculate_total(double exam1[],double exam2[],double exam3[])
{
int calc_tot,above90=0, above80=0, above70=0, above60=0,i,j, fail=0;
double exam[100][3]; …Run Code Online (Sandbox Code Playgroud) 我不知道如何解决这些错误.我写了整个代码,并试图看看它是否是括号的问题,但也没有帮助.我不知道它是什么线但我相信它是在这个功能.
错误LNK2019:未解析的外部符号"int __cdecl read_file_in_array(int(*const)[3])"(?read_file_in_array @@ YAHQAY02H @ Z)在函数_main致命错误中引用LNK1120:1未解析的外部
我相信这个与括号有关
#include <iostream>
#include <fstream>
using namespace std;
int read_file_in_array(int exam[100][3]);
double calculate_total(int exam1[], int exam2[], int exam3[]); // function that calcualates grades to see how many 90,80,70,60
//void display_totals();
double exam[100][3];
int read_file_in_array(double exam[100][3])
{
ifstream infile;
int exam1[100];
int exam2[100];
int exam3[100];
infile.open("grades.txt");// file containing numbers in 3 columns
if(infile.fail()) // checks to see if file opended
{
cout << "error" << endl;
}
int num, i=0,j=0;
while(!infile.eof()) // reads …Run Code Online (Sandbox Code Playgroud)