Hi all,
I am not a c programmmer but was thrown into fixing a program. Below is the string sp_amount. Right now with code bellow the print out on the paper improperly.
sp_amount:
Ninety-Nine Million Nine Hundred Ninety-Nine Thousand Nine Hundred Ninety-Nine Dollars And 99 Cents
Prints like the following:
(1st line)
Ninety-Nine Million Nine Hundred Ninety-Nine Thousand Nine Hundred Ninety-Nine Dollars An
(second line)
Cents*************************************************
As you can see there is wording missing. If I change the position to move more to the left it prints properly. But, I would like to keep the position it is at right now and add a caridge return at the first blank character after the 70th character. Does anyone know how to do this. I have the code bellow.
Ideally it would look like this:
(1st line)
Ninety-Nine Million Nine Hundred Ninety-Nine Thousand Nine Hundred Ninety-Nine
(2nd)
Dollars And 99 Cents*******************************
/* if the string is less then 70 prints on first line followed by **** */
if (strlen(cheque.sp_amount) < 70)
{
memset(buf, '*', sizeof(buf));
buf[70] = NULL;
memcpy(buf, cheque.sp_amount, strlen (cheque.sp_amount));
POS(1);
fprintf(fd, "%s\r\n\r\n\r\n", buf);
}
else
{
/*if string longer then 70 print first 70 chars then caridge return and print on second line followed by **** */
ptr = strrchr(cheque.sp_amount, ' ');
*ptr = NULL;
ptr++;
POS(1);
fprintf(fd, "%s --\r\n", cheque.sp_amount);
memset(buf, '*', sizeof(buf));
buf[70] = NULL;
memcpy(buf, ptr, strlen(ptr));
POS(1.5);
fprintf(fd, "%s\r\n\r\n", buf);
}
I am not a c programmmer but was thrown into fixing a program. Below is the string sp_amount. Right now with code bellow the print out on the paper improperly.
sp_amount:
Ninety-Nine Million Nine Hundred Ninety-Nine Thousand Nine Hundred Ninety-Nine Dollars And 99 Cents
Prints like the following:
(1st line)
Ninety-Nine Million Nine Hundred Ninety-Nine Thousand Nine Hundred Ninety-Nine Dollars An
(second line)
Cents*************************************************
As you can see there is wording missing. If I change the position to move more to the left it prints properly. But, I would like to keep the position it is at right now and add a caridge return at the first blank character after the 70th character. Does anyone know how to do this. I have the code bellow.
Ideally it would look like this:
(1st line)
Ninety-Nine Million Nine Hundred Ninety-Nine Thousand Nine Hundred Ninety-Nine
(2nd)
Dollars And 99 Cents*******************************
/* if the string is less then 70 prints on first line followed by **** */
if (strlen(cheque.sp_amount) < 70)
{
memset(buf, '*', sizeof(buf));
buf[70] = NULL;
memcpy(buf, cheque.sp_amount, strlen (cheque.sp_amount));
POS(1);
fprintf(fd, "%s\r\n\r\n\r\n", buf);
}
else
{
/*if string longer then 70 print first 70 chars then caridge return and print on second line followed by **** */
ptr = strrchr(cheque.sp_amount, ' ');
*ptr = NULL;
ptr++;
POS(1);
fprintf(fd, "%s --\r\n", cheque.sp_amount);
memset(buf, '*', sizeof(buf));
buf[70] = NULL;
memcpy(buf, ptr, strlen(ptr));
POS(1.5);
fprintf(fd, "%s\r\n\r\n", buf);
}