This is a file name valid.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "valid.h"
#include "structure.h"
int checkCode(char* codeString,DATA_T* pResult)
{
int status = 1;
int i = 0;
char countryCode[3];
char passportNum[13];
if((strlen(codeString)<11)||(strlen(codeString)>15))
{
status = ERR_BADFORM;
}
else if (codeString[2] != '-')
{
status = ERR_BADFORM;
}
else
{
/* check that the first two are alphabets */
for (i = 0; (i < 2) && (status > 0); i++)
{
if (!isalpha(codeString[i]))
{
status = ERR_CODE;
}
if ((codeString[i]<=97)||(codeString[i]>=122))
{
codeString[i] = codeString[i] - 32;
}
}
/* check that all other chars are digits */
for (i = 2; (i < 13) && (status > 0); i++)
{
if (!isdigit(codeString[i]))
{
status = ERR_NUM;
}
}
/* If the status is still positive, then we know the format is good */
if (status > 0)
{
sscanf(codeString,"%s-%s",countryCode,passportNum);
strcpy(pResult->passportID,countryCode);
strcat(pResult->passportID,"-");
strcat(pResult->passportID,passportNum);
}
}
return status;
}
This is a file name valid.h
Code:
#define ERR_BADFORM -10
#define ERR_CODE -11
#define ERR_NUM -12
int checkCode(char* codeString,DATA_T * pResult);
This is a file name structure.h
Code:
typedef struct
{
char passportID[16]; /* Passport ID of the user */
char firstName[30]; /* First name of the user */
char lastName[30]; /* Last name of the user */
char expireDate[10]; /* Expiration date of the passport */
char entryDate[10]; /* Date of last entry into Thailand */
char exitDate[10]; /* Date of last exit from Thailand */
char visaType[30]; /* Type of visa */
} DATA_T;
I've been getting error in the valid.h saying that
the red line: error: syntax error before DATA_T
Can anyone help me with this?
Thank you