09-19-2006, 04:26 AM
How do I combine two strings together. I need the C equivalent of
I can't figure out how to do it. Also, I'm getting some warning that I don't quite understand. Where are the two warning coming from (I know the printf, but why?) and what does it mean by Undefined symbols. All of those functions are declared in
Grr. I usually don't post homework, but I've spent a lot of time trying to figure this out for myself, but haven't been able to get it. Thanks in advance.
EDIT: I'm using GNU C compiler for OSX, which is UNIX.
Code:
return name + " in " + department;
I can't figure out how to do it. Also, I'm getting some warning that I don't quite understand. Where are the two warning coming from (I know the printf, but why?) and what does it mean by Undefined symbols. All of those functions are declared in
Quote:driver.c: In function 'main':
driver.c:24: warning: incompatible implicit declaration of built-in function 'printf'
driver.c:28: warning: incompatible implicit declaration of built-in function 'printf'
/usr/bin/ld: Undefined symbols:
_MajortoString
_StudenttoString
_getMajor
_newmajor
_newstudent
collect2: ld returned 1 exit status
Code:
#include "student.h" //everything i need is in this header and associated files
int main(int argc, char **argv){
int i, temp;
major_t *majors[] = {
newmajor("Computer Science", "Computer Science"),
newmajor("Mathematics", "Mathematics"),
newmajor("Math Ed", "Mathematics"),
newmajor("CS Grad", "Computer Science"),
newmajor("Olde Englishe", "English")
};
student_t *students[] = {
newstudent("Joe", 17, majors[0], 3.5f),
newstudent("Jane", 18, majors[1], 3.8f),
newstudent("Jack", 17, majors[2], 2.5f),
newstudent("Jill", 22, majors[3], 4.0f),
newstudent("John", 24, majors[4], 1.0f)
};
if (argc > 0){
for (i = 0; i < 4; i++){
if (MajortoString(getMajor(students[i])) == argv[1])
printf("%s\n", StudenttoString(students[i]));
}
}
else
printf("%s", "You must enter a Major name at the command line... dumbass!");
}
Grr. I usually don't post homework, but I've spent a lot of time trying to figure this out for myself, but haven't been able to get it. Thanks in advance.
EDIT: I'm using GNU C compiler for OSX, which is UNIX.
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.