Hi I cant seem to find what is wrong with my programming. I keep on getting the LNK2019 error and the LNK1120 fatal error. here is my code.
# include <iostream>
using namespace std;
struct StudentRecord
{
int hrs;
double gpa;
bool in_state;
double tuition;
};
void get_student_info (int&hrs, double&gpa, bool&state);
double calculate_tuition (StudentRecord student1);
void main ()
{
int h;
double gpa;
bool state;
get_student_info (h, gpa, state);
StudentRecord student;
student.hrs=h;
student.gpa=gpa;
student.in_state=state;
double final_amount;
final_amount=calculate_tuition(student);
cout<<"Your tuition is: "<<final_amount<<"\n";
system ("pause");
}
void get_student_info (int&hrs, double&gpa, bool&state)
{
char in_state;
cout<<"\nEnter the amount of credit hours your are taking for the semester: ";
cin>>hrs;
cout<<"\nEnter your gpa: ";
cin>>gpa;
cout<<"\nAre you a state resident Y/N: ";
cin>>in_state;
if(in_state=='Y'||in_state=='y')
{
state=true;
}
}
double calculate_tution(StudentRecord student1)
{
if (student1.gpa>=3.0)
student1.tuition=student1.hrs*50;
else if (student1.in_state=true)
student1.tuition= student1.hrs*100;
else
student1.tuition=student1.hrs*200;
return (student1.tuition);
}
99% of the time, "unresolved external symbol" means that you have a prototype for a funciton, but never gave that function a body -- or the body of that function cannot be found.
The function whose body can't be found here is calculate_tuition. Compare your prototype:
My teacher gave me a file full of words. I saved it to my desktop and now I want to read in that file. I am suppose to create two arrays, one array to store the words and another to store Keys. Then I am to sort the arrays using a bubble sort.
I am basically at a loss. I have tried to piece this thing together as best I can.
#include <iostream>
#include <iomanip>
#include <fstream>// to read from and to a file
using namespace std;
char** read(const char* fileName, int& count); // function prototype
{
std::ifstream countingStream(fileName);
// first count them
count = 0;
while (true) {
char line[100];
countingStream.getline(line, 100);
if (strlen(line) == 0) {
break;
}
count += 1;
}
countingStream.close();
std::ifstream readingStream(fileName); // reading ifstream produces a char array
char** words = new char* [count];// char array called words
for (int index = 0; index < count; ++index) {
char line[100];
readingStream.getline(line, 100);
words[index] = _strdup(line);
cout<<setw(15)<<left<<words[index];//this will allow me to “see” my words
std::cout << line << std::endl;
}
readingStream.close();
return words;
}
int main (int argc, char * const argv[])
{
int count;
int element;
char** wordList = read("C:\\Users\\Maureen\\Desktop\\words.txt",count);
return 0;
- One should be "Unresolved external symbol" or something similar (this one tells you what the symbol is)
- The other is what you posted (saying you have 1 unresolved symbol, but not specifying what that symbol is)
Tell me what the symbol is and/or post the full error page so I can help.
I tried compiling on my own but ran into all sorts of other errors I didn't feel like fixing (stray semicolon after read, you're not including <cstring> like you should be, and wtf is _strdup?)