hey everyone i am getting something like this
Record found at index -1
with some weird characters 45 p 00/3434983984/349834
when i am suppose to be getting a name the grade and a birthdate
Code:int srch (STUDENT student[], char* ssn) { char Name[256]; int tempstu; while ((strcmp(ssn, "q"))) { printf("\n Please enter social security number (press q to quit): "); scanf("%s", ssn); tempstu = recSrch(student, ssn, 0, SIZE - 1); printf("\nRecord found at index %d:", tempstu); strcat(strcat(strcpy(Name, student[tempstu].fName), " "), student[tempstu].lName); printf("\n%30s %9d %13s %02d/%02d/%4d", Name, student[tempstu].grade, student[tempstu].ssn, student[tempstu].bDate.month, student[tempstu].bDate.date, student[tempstu].bDate.year); } printf("\nThank You."); } /*===============================recSrch=====================================*/ // this function searches for the input social security number and returns // the result int recSrch (STUDENT student[], char* ssn, int lb, int ub) { int result; int mid = (lb + ub) / 2; if (lb > ub) { result = -1; } else if (strcmp(ssn, student[mid].ssn) == 0) { result = mid; } else if (strcmp(ssn, student[mid].ssn) < 0) { result = recSrch(student, ssn, lb, mid - 1); } else { result = recSrch(student, ssn, mid + 1, ub); } return result; }



LinkBack URL
About LinkBacks



