Code:
/* basicinput.c by Aron, 11/21/05 */
/* This program shows basic information about a customer using strings
* The strings are copied inton on string at the end */
#include <stdio.h>
#include <string.h>
int fixgets(char *, int ,FILE *);
int main ()
{
/* Declarations */
char cusnum[7], fname[16], mi[2], lname[26], address[31], city[16], st[3], zcode[11], phone[13];
char combo[134];
/* Input Section */
printf("Customer Number ");
fixgets(cusnum, 7, stdin);
printf("\nFirst Name ");
fixgets(fname, 16, stdin);
printf("\nMiddle Initial ");
fixgets(mi, 2, stdin);
printf("\nLast Name ");
fixgets(lname, 26, stdin);
printf("\nAddress ");
fixgets(address, 31, stdin);
printf("\nCity ");
fixgets(city, 16, stdin);
printf("\nState ");
fixgets(st, 3, stdin);
printf("\nZip Code ");
fixgets(zcode, 11, stdin);
printf("\nPhone ");
fixgets(phone, 13, stdin);
/* Processing */
strcpy(combo, cusnum);
strcat(combo, " / ");
strcpy(combo, lname);
strcat(combo, ", ");
strcpy(combo, fname);
strcpy(combo, mi);
strcat(combo, " / ");
strcpy(combo, address);
strcat(combo, " / ");
strcpy(combo, city);
strcat(combo, ", ");
strcpy(combo, st);
strcat(combo, " ");
strcpy(combo, zcode);
strcat(combo, " / ");
strcpy(combo, phone);
/* Output */
printf("\n%s\n", combo);
return 0;
}
/* This routine fixes fgets incorporation of line feeds and other
* ASCII values less than 32 into an input string. Written by H. Brown.
*/
int fixgets(char input_array[], int length, FILE *file_name)
{
register int position=0;
if (fgets(input_array,length,file_name) != NULL)
{
while(input_array[position] != 0)
{ if (input_array[position] < 32) input_array[position]=0;
else ++position;
}
}
/* The length of the string is returned. */
fflush(stdin);
return position;
}
The problem I have is that in the output section all it lists is the phone number, not "A12345 / Jones, James E / 234 S. Maple Street / San Fran, Ca 12345 / 345-123-4567". Not sure what I'm doing wrong. Any help is appreciated.