Hi, and thanks for looking.
What I am trying to do is have a struct and read from a file and output it to screen and file.
Here is the code (just really basic to get the point)
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
|
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
struct list
{
string name;
} student;
int main ()
{
ifstream inFile;
ofstream outFile;
inFile.open("student-input.txt");
outFile.open("student-output.txt");
cout << "Processing data" << endl;
inFile >> student.name;
outFile << "Student name: " << student.name << endl;
cout << "Student name: " << student.name;
inFile.close();
outFile.close();
cin.get(); //to keep visual c++ open
return 0;
}
|
Alright the error I get is
1>------ Build started: Project: Struct2, Configuration: Debug Win32 ------
1>Compiling...
1>struct.cpp
1>Linking...
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Nightmare\Documents\Visual Studio 2008\Projects\Struct2\Debug\Struct2.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Nightmare\Documents\Visual Studio 2008\Projects\Struct2\Struct2\Debug\BuildLog.htm"
1>Struct2 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
and I am not sure where that is? When I click to go to error on the link, it just highlights the line in the log and not in the code.
My text file is basic
Richard
saved in the file in the folder under projects.
I can get reading from a file to work in just main with no structs but not able to do this. Any tips would be appreciated.
Thanks
Akumanight