1) Proper way to close a code tag is with [/code]
2) // is C++ unless you have a C99 compiler. /* */ is the correct comment usage in C
3)
Code:
fgets( strPatientAddress, sizeof(strPatientAddress), stdin);
//checks to see if variable contains a value
if (fgets(strPatientAddress, sizeof(strPatientAddress), stdin) != NULL)
Is asking the user to input the data TWICE. Remove the call before the if statement here and in the call for the City and it should work.
4) Don't mix scanf and fgets. Use fgets to get the state also.
Code:
#include <stdio.h>
#include <string.h>
int main (void)
{
char strPatientAddress[BUFSIZ];
char strPatientCity[BUFSIZ];
char strPatientState[50];
char *p;
char *a;
printf(" Please enter in data for the following:\n\n");
printf(" Address: ");
/*checks to see if variable contains a value*/
if (fgets(strPatientAddress, sizeof(strPatientAddress), stdin) != NULL)
{
/*test for and remove newline character*/
if ((p = strchr(strPatientAddress, '\n')) != NULL)
*p = '\0';
}
printf("\n City: ");
/*checks to see if variable contains a value*/
if (fgets(strPatientCity, sizeof(strPatientCity), stdin) != NULL)
{
/*test for and remove newline character*/
if ((a = strchr(strPatientCity, '\n')) != NULL)
*a = '\0';
}
printf("\n State Initials: ");
scanf(" %s", strPatientState);
printf("\n");
/* My Addition to make sure correct info was recieved */
printf("%s\n%s, %s\n", strPatientAddress, strPatientCity, strPatientState);
}