Getline string

Hello, I keep encountering an issue in my read file function, I'm trying to use pass the code from an input file as a string, but I keep getting the message" no matching function for call to `getline(std::basic_ifstream<char, std::char_traits<char> >&, char[30], char)' "

Any suggestions or help would be useful.
Thanks in advanced.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>   //cin, cout
#include <string> //setw, setprecision, fixed
#include <fstream> // File stream thingy
#include <cstring>
using namespace std;  

 void openfile(ifstream &outputfile);
 void inputfile(ofstream &intofile); 
 void readFile ( ofstream &intofile, ifstream &outputfile );
 const int SIZE = 30;
 
 
int main ()
{
  ifstream outputfile;
  ofstream intofile;
  char input[SIZE];
  
  openfile(outputfile);
  inputfile(intofile);
  readFile (intofile, outputfile);
  
   
system ("pause"); 
return 0; 
}

  void openfile(ifstream &outputfile)
   {
    outputfile.open ("lab3input.txt"); //open in file
     if (!outputfile)
      {
      cout << "File did not open properly!1"<< endl;
      system ("pause"); 
      exit(EXIT_FAILURE);
      } 
   }
 //Purpose: to open a file and check to see if file opens 
  void inputfile(ofstream  &intofile)
   {
    intofile.open ("lab3output.txt"); //open in file
    if (!intofile)
    {
    cout << "File did not open properly!2"<< endl;
    system ("pause"); 
    exit(EXIT_FAILURE);
    }  
   }

  
void readFile ( ofstream &intofile, ifstream &outputfile )
 {
     char lname[SIZE], fname[SIZE], address [SIZE],city [SIZE], zip [SIZE],
          state [SIZE]; 

     while (getline(outputfile,lname, '^'))
     {    

     }
 }
 
You can't use getline() with char arrays. Use an std::string instead. This will also mean you can accept input of any length.
Topic archived. No new replies allowed.