Hi.
I have this program that is supposed to take a tab delim file and create a fixed length. When I comppile this code it gives an error: E:\dialer_conversion.cpp(35) : error C2664: 'fgets' : cannot convert parameter 3 from 'char *' to 'struct _iobuf *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast.
I can't figure this out. Any help will be appreciated. If there is some material I can read on this or if someone knows a fix anything will help. Code below.
I have this program that is supposed to take a tab delim file and create a fixed length. When I comppile this code it gives an error: E:\dialer_conversion.cpp(35) : error C2664: 'fgets' : cannot convert parameter 3 from 'char *' to 'struct _iobuf *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast.
I can't figure this out. Any help will be appreciated. If there is some material I can read on this or if someone knows a fix anything will help. Code below.
Code:
// this program will open a tab file and save as fixed length
#include <stdio.h>
int main()
{
// set file pointers
FILE *dialPtr;
FILE *smartPtr;
// input tab file name
char *myFile;
//input file to convert
printf("Enter the file to convert: (dialer.txt).\n> ");
scanf("%s", myFile);
//check if files are open
if (((dialPtr = fopen (myFile, "r")) = NULL) && ((smartPtr = fopen ("smartout.txt", "w")) = NULL))
//if not open
{
printf("Unable to open file.\n");
}
else{
//process files
char line[4096];
while (fgets(line, sizeof(line), myFile))
{
char *rec;
char *clNum;
char *clName;
int acct;
char *dbtr;
char *addy;
int phone;
char *pt;
int assign;
char *stat;
char *desk;
int tot;
int lstPay;
int lstWork;
char *state=line;//buffer
//extract info from buffer
rec = "REC00004A1";
clNum = strsep(&state, "\t");
clName = strsep(&state, "\t");
acct = atoi(strsep(&state, "\t"));
dbtr = strsep(&state, "\t");
addy = strsep(&state, "\t");
phone = atoi(strsep(&state, "\t"));
pt = strsep(&state, "\t");
assign = atoi(strsep(&state, "\t"));
stat = strsep(&state, "\t");
desk = strsep(&state, "\t");
tot = atoi(strsep(&state, "\t"));
lstPay = atoi(strsep(&state, "\t"));
lstWork = atoi(strsep(&state, "\t\r\n"));
//send to file
fprintf(smartPtr, "%-10s%-10s%-30s%-10d%-10d%-30s%-25s%-10d%-30s%-6d%3s%-5s%5d%-8d%14d%-6d\n", rec, clNum, clName, phone, account, dbtr, addy, phone, pt, assign, stat, desk, tot, tot, lstPay, lstWork);
}
//close files
fclose(smartPtr);
fclose(dialPtr);
}
//success
return 0;
}
[\code]