I'm getting the following error when trying to write to a file:
1>Linking...
1>mit_lesson1.obj : error LNK2019: unresolved external symbol "int __cdecl do_stuff(int,int,int,int)" (?do_stuff@@YAHHHHH@Z) referenced in function _main
1>C:\Users\Michael\Documents\Visual Studio 2008\Projects\MIT\Debug\MIT.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Michael\Documents\Visual Studio 2008\Projects\MIT\MIT\Debug\BuildLog.htm"
1>MIT - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any advice would be deeply appreciated! Thanks!
#include <iostream>
#include <fstream>
using namespace std;
int by_reference(int &n1, int &n2, int &n3, int &n4);
int do_stuff(int n1_val, int n2_val, int n3_val, int n4_val);
//int swap_stuff(int &n1,int &n4);
void write_file(int n1, int n2, int n3, int n4);
int main()
{
int n1,n2,n3,n4;
by_reference(n1,n2,n3,n4); //call by_reference
do_stuff(n1,n2,n3,n4); //call do_stuff
//swap_stuff(n1,n4); //call swap_stuff
system("pause");
system("CLS");
cout<<"Results after the swap"<<endl;
cout<<n1<<endl;
cout<<n2<<endl;
cout<<n3<<endl;
cout<<n4<<endl;
write_file(n1,n2,n3,n4);
system("pause");
return 0;
}
int by_reference(int &n1, int &n2, int &n3, int &n4)
//get the values from user by reference and display//
{
cout<<"Please enter a number for n1:"<<endl;
cin>>n1;
system("CLS");
cout<<"Please enter a number for n2:"<<endl;
cin>>n2;
system("CLS");
cout<<"Please enter a number for n3:"<<endl;
cin>>n3;
system("CLS");
cout<<"Please enter a number for n4:"<<endl;
cin>>n4;
system("CLS");
return n1,n2,n3,n4;
}
int do_stuff(int &n1_val,int &n2_val,int &n3_val,int &n4_val)
{
int temp;
temp = n1_val;
n1_val = n4_val;
n4_val= temp;
return n1_val,n2_val,n3_val,n4_val;
}
/*int swap_stuff(int &n1,int &n4)
//Swap n1 and n4//
{
int temp;
temp = n1;
n1=n4;
n4=temp;
return n1,n4;
} */
void write_file(int n1, int n2, int n3, int n4)
{
cout<<"Writing results to a file..."<<endl;
ofstream myfile;
myfile.open("stuff.dat");
myfile<<"These are the results of n1, n2, n3,and n4: "<<n1<<n2<<n3<<n4;
myfile.close();
return;
}