stack
stack

Reputation: 414

unresolved external symbol _printf referenced in function in C

I've read through some of the solution, such as change the linker, include / and even clean the whole project. It doesn't seems to solve this issue that I'm facing.

Error   LNK2019 unresolved external symbol _print referenced in function _sortEmployees

I'm only trying to run the sortedEmployees function

#include "testing.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(void){
    /*You are NOT allowed to modify the code of this function*/
    sortEmployees(sampleEmployeeList);
    readFromFile("employees.txt");
    Node *head = youCanIgnoreThisFunction(sampleEmployeeList);
    Node *employeeNode = malloc(sizeof(Node));
    Employee e = { "Newbie", 10000 };
    employeeNode->employee = e;
    addNode(employeeNode, head, 0);
    getch();
}

void sortEmployees(Employee elist[]){
    printf("EMPLOYEE REPORT\n");
    printf("%-25s%-10s\n", "Employee_name", "Salary");
    printf("%-25s%-10s\n", "------------", "-----");

    int i, j;
    Employee temp;
    for (i = 0; i < MAX; i++) {
        printf("%-25s%-10s\n", elist[i].name,elist[i].salary);
    }
    print("After Sorting");

    for (i = 0; i < MAX -1; i++) {
        for (j = i + 1; j < MAX; j++) {
            if (strcmp(elist[j].name, elist[j + 1].name) > 0) {
                temp = elist[j];
                elist[j] = elist[j + 1];
                elist[j + 1] = temp;
            }
        }
    }
    for (i = 0; i < MAX; i++) {
        printf("%-25s%-10s\n", elist[i].name, elist[i].salary);

    }

}

void readFromFile(char fileName[]){

    FILE *filePtr = fopen(fileName, "r");
    if (filePtr == NULL){
        printf("File could not be opened\n");
        return;
    }
    printf("\nEmployee list from file %s\n", fileName);
    printf("%-25s%-10s\n", "Employee_name", "Salary");
    printf("%-25s%-10s\n", "------------", "-----");
    char name[20];
    int examScore;

    /*not done*/

    fclose(filePtr);
}

void addNode(Node *nodePtr, Node *headPtr, int pos){


    /*not done*/
    printEmployeeList(headPtr);
}



void printEmployeeList(Node *headPtr){
    /*You are NOT allowed to modify the code of this function*/
    printf("%-25s%-10s\n", "Employee_name", "Salary");
    printf("%-25s%-10s\n", "------------", "-----");
    while (headPtr != NULL){
        printf("%-25s%-10d\n", headPtr->employee.name, headPtr->employee.salary);
        headPtr = headPtr->next;
    }
}

Node *youCanIgnoreThisFunction(Employee employeeList[]){
    /*You are NOT allowed to modify the code of this function*/
    Node *list = NULL;

    for (int i = 0; i < MAX; i++)
    {
        Node *employeeNode = malloc(sizeof(Node));
        employeeNode->employee = employeeList[i];
        list = youCanIgnoreThisFunctionToo(employeeNode, list);
    }
    return list;
}

Node *youCanIgnoreThisFunctionToo(Node *nodePtr, Node *headPtr){
    /*You are NOT allowed to modify the code of this function*/
    nodePtr->next = headPtr;
    headPtr = nodePtr;
    return headPtr;
}

Upvotes: 0

Views: 3946

Answers (1)

Andrej Adamenko
Andrej Adamenko

Reputation: 1668

Try replacing

print("After Sorting");

with

printf("After Sorting");

Upvotes: 3

Related Questions