我正在构建一个以这种格式获取输入文件的程序:
title author
title author
etc
and outputs to screen
title (author)
title (author)
etc
Run Code Online (Sandbox Code Playgroud)
我目前遇到的问题是错误:
"ifstream infile的类型不完整,无法定义"
以下是该计划:
#include <iostream>
#include <string>
#include <ifstream>
using namespace std;
string bookTitle [14];
string bookAuthor [14];
int loadData (string pathname);
void showall (int counter);
int main ()
{
int counter;
string pathname;
cout<<"Input the name of the file to be accessed: ";
cin>>pathname;
loadData (pathname);
showall (counter);
}
int loadData (string pathname) // Loads data from infile into arrays
{
ifstream infile; …Run Code Online (Sandbox Code Playgroud) 继承我的代码我试图整理学校,在嵌入式if和else if语句中,当我尝试编译时它显示错误.
错误:期望在"else"之前的primary-expression';' 在别的之前
这两个都出现在每一行.
// This is a program to Calculate the volume of the sphere using the radius (a03.cpp)
// Written by: Jimmy Scott
// Date: 2/1/12
// Sources: Stackoverflow.com (else and if statements)
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main ()
{
char vehicle;
float total;
char over20;
char old;
int adults;
int oldpass;
char height;
int youngpass;
int bicycles;
float length;
cout<<"Fare Calculator by Jimmy Scott";
cout<<"\n\n\n Are You Bringing a vehicle …Run Code Online (Sandbox Code Playgroud)