Linker Command Failed??

I am supposed to make a program that inputs user's name, birthdate, and grade (in percent) and display all of that with the grade (letter). It works perfectly fine, but I wanted to verify that the user's name didn't contain numbers. Now is when I get the errors. Here is my code (I am running this in XCode):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

struct Person
{
    string lastName, firstName;
};

struct GradeRec
{
    float percent;
    char grade;
};

struct Student
{
    Person name;
    int birthYear, birthMonth, birthDay;
    GradeRec courseGrade;
};

void printStudent (Student student[], int count);
void assignGrade (Student student[], int count);
bool verifyString (string c);

int main()
{
    int count = 0, i;
    bool isString;
    
    struct Student person[30];
    

    do
    {
        for (i = 0; i < 30; i++)
        {
            cout << "What is student #" << count + 1 << "'s first name?" 
                   << "(q to quit if you are done entering at least one student)" << endl;
            cin >> person[i].name.firstName;
            count++;
        
            if ((person[i].name.firstName == "q" 
                   || person[i].name.firstName == "Q") && count >= 1)
            {
                count--;
                goto stop;
            }
            
            isString = verifyString(person[i].name.firstName);
            
            while (isString == true)
            {
                cout << "Name can not contain numbers. Try again: ";
                cin >> person[i].name.firstName;
                isString = verifyString(person[i].name.firstName);
                cout << endl;
            }
            
            cout << "What is " << person[i].name.firstName << "'s last name? " << endl;
            cin >> person[i].name.lastName;
            
            isString = verifyString(person[i].name.lastName);
            
            while (isString == true)
            {
                cout << "Name can not contain numbers. Try again: ";
                cin >> person[i].name.lastName;
                isString = verifyString(person[i].name.lastName);
                cout << endl;
            }
            
            cout << "What is " << person[i].name.firstName << "'s grade? (in percent)?" << endl;
            cin >> person[i].courseGrade.percent;
            
            while (cin.fail())
            {
                cout << "Not a valid grade. Try again: ";
                cin >> person[i].courseGrade.percent;
                cout << endl;
            }
            
            cout << "What is " << person[i].name.firstName << "'s birthday?" 
                   << "(enter as mm dd yyyy, eg 7 26 2004) " << endl;
            cin >> person[i].birthMonth >> person[i].birthDay >> person[i].birthYear;
            
            while (cin.fail())
            {
                cout << "Not a valid birth date. Try again: ";
                cin >> person[i].birthMonth >> person[i].birthDay >> person[i].birthYear;
                cout << endl;
            }
            
            cout << "Thank you.\n" << endl;
        }
    } while ((person[i].name.firstName != "q" || person[i].name.firstName != "Q") && count <= 30);
    
    stop:
    assignGrade(person, count);
    printStudent(person, count);

    cout << "Thanks for using this application! " << endl;
}

void assignGrade (Student student[], int count)
{
    for (int i = 0; i < count; i++)
    {
        if (student[i].courseGrade.percent > 89)
            student[i].courseGrade.grade = 'A';
    
        else if (89 >= student[i].courseGrade.percent && student[i].courseGrade.percent > 79)
            student[i].courseGrade.grade = 'B';
    
        else if (79 >= student[i].courseGrade.percent && student[i].courseGrade.percent > 69)
            student[i].courseGrade.grade = 'C';
    
        else if (69 >= student[i].courseGrade.percent && student[i].courseGrade.percent > 59)
            student[i].courseGrade.grade = 'D';
    
        else
            student[i].courseGrade.grade = 'F';
    }
}

void printStudent (Student student[], int count)
{
    for (int j = 0; j < count; j++)
    {
        cout << "Student #" << j + 1 << ": " << endl;
        cout << "Name: " << student[j].name.firstName << " " << student[j].name.lastName << endl;
        cout << "Birthdate: " << student[j].birthMonth << "/" << student[j].birthDay << "/"
             << student[j].birthYear << endl;
        cout << "Grade (percent): " << student[j].courseGrade.percent << "%" << endl;
        cout << "Grade (letter): " << student[j].courseGrade.grade << endl << endl;
    }
}

bool verifyString (char *pass)
{
    bool isDigit = false;
    int i = 0;
    
    while (pass[i])
    {
        if (isalpha(pass[i]))
            isDigit = true;
        
        i++;
    }
    
    return isDigit;
}


Here is my output:
Apple Mach-O Linker (ld) Error Group
  "verifyString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Any help is appreciated. Thanks!

(I'm sure there will be some people who will get triggered at my goto. For you, go here: http://stackoverflow.com/questions/24451/is-it-ever-advantageous-to-use-goto-in-a-language-that-supports-loops-and-func/2809622#2809622)
Last edited on
closed account (48T7M4Gy)
bool verifyString (string c); line 26 vs bool verifyString (char *pass) line 141

Must have compatible types. Make it:

1
2
3
bool verifyString (string pass)
{
    bool isDigit etc etc
Last edited on
Topic archived. No new replies allowed.