D
David Hoffman
When I compile it, I get a "error C2664: 'ExtractID' : cannot convert
parameter 1 from 'char' to 'char []'" error and I don't understand why.
I am just learning C++, so keep it simple. One more note, I have the
program compiled using strings instead of char[]; however, I should be
able to convert all my strings to char[] and get the program to
compile. Right? Here is my code. Thanks.
// Written by David Hoffman
// Sept 30, 2003
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//Function Prototypes
bool TestValidLine(char[]);
void ExtractID(char[], char[]);
int main()
{
char cRawLine[70];
char cidNumber[8];
bool bLastGood = true;
char wait;
ifstream RawList;
ofstream NewList;
RawList.open("RAWLIST.txt");
NewList.open("NEWLIST.txt");
//Loop while not EOF and the last line read was valid.
while (RawList.getline(cRawLine, 80) && bLastGood)
{
bLastGood = TestValidLine(cRawLine);
if (bLastGood)
{
//Extract data from line.
ExtractID(cRawLine[70], cidNumber[8]);
cin >> wait;
}
}
//Close files here.
RawList.close();
NewList.close();
return 0;
}
bool TestValidLine(char cRawLine[])
{
return ((cRawLine[0] == '|') && (cRawLine[strlen(cRawLine)] == '|'));
}
void ExtractID(char cRawLine[], char cidNumber[])
{
int x;
for (x = 0; x <= 6; x++)
{
cidNumber[x] = cRawLine[x + 6];
}
cout << cidNumber << "\n";
}
parameter 1 from 'char' to 'char []'" error and I don't understand why.
I am just learning C++, so keep it simple. One more note, I have the
program compiled using strings instead of char[]; however, I should be
able to convert all my strings to char[] and get the program to
compile. Right? Here is my code. Thanks.
// Written by David Hoffman
// Sept 30, 2003
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//Function Prototypes
bool TestValidLine(char[]);
void ExtractID(char[], char[]);
int main()
{
char cRawLine[70];
char cidNumber[8];
bool bLastGood = true;
char wait;
ifstream RawList;
ofstream NewList;
RawList.open("RAWLIST.txt");
NewList.open("NEWLIST.txt");
//Loop while not EOF and the last line read was valid.
while (RawList.getline(cRawLine, 80) && bLastGood)
{
bLastGood = TestValidLine(cRawLine);
if (bLastGood)
{
//Extract data from line.
ExtractID(cRawLine[70], cidNumber[8]);
cin >> wait;
}
}
//Close files here.
RawList.close();
NewList.close();
return 0;
}
bool TestValidLine(char cRawLine[])
{
return ((cRawLine[0] == '|') && (cRawLine[strlen(cRawLine)] == '|'));
}
void ExtractID(char cRawLine[], char cidNumber[])
{
int x;
for (x = 0; x <= 6; x++)
{
cidNumber[x] = cRawLine[x + 6];
}
cout << cidNumber << "\n";
}