Every time I try to build this code I get an error,
"No matching function for call to getline()"
But I've used it before and it worked fine? S I'm not sure what's going on. I'm using Mavericks OSX if that would be anything, and using Xcode to build this project. It's for school. I know the inputFile is working correctly, because I have commented the getline() and "Open" printed to the console.
//
// main.cpp
// Project 4
//
// Created by Eric Diviney on 10/27/13.
// Copyright (c) 2013 Eric Diviney. All rights reserved.
//
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
/*
|
|-------------------------------------------------------------
| Documentation
|-------------------------------------------------------------
| The headings[] array will contain all strings for the customer's receipt.
| the 2nd level of headings[][] will contain all of the info (name, address etc.) while
| the first level of headings[] will contain the number of customers. The order of the second level is heading1, heading2, customername,
| address, phone, footer
|
| The charges[] array will contain all double/floats required to compute the charges for the customer.
| The third level of charges[][][] will contain the actual charges/prices while the first level
| will hold n amount of customers. The second level of that array (charges[][]) will hold the first, second and third month.
| The order of the last array is electricity, water, and gas
|
| The output[] array is 3 customers in the first level (output[]) and the correspnding strings for each
| segment of their receipt output[][]. The order in the second level of this array is heading1, heading2, customerName, Customer address,
| customer Phone, Customer ID, electricity, water, gas, subtotal, discountRate, taxRate, tax for order, discount for order, order total,
| footer
|
*/
// variable declarations
string headings[3][7];
double charges[3][3][3];
string output[3][16];
ifstream inputFile;
inputFile.open("/Users/ericdiviney/Documents/workspace/project4/project4/input.txt");
if(inputFile.is_open())
{
cout << "Open" << endl;
}
getline(inputFile, headings[0][0], "*");
//cout << headings[0][0];
return 0;
}
The third parameter is a single character, so you need
getline(inputFile, headings[0][0], '*');
Note the single quotes. "*"
is a null-terminated string literal, with type const char[2]
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.