Hi guys, when I was working on this game for school I ran into a weird linker error, LNK2019. It bugs me to no avail, so hopefully you guys can help me. It seems to be a problem with the string pas. I submitted alternate values for where they would be referenced in other header files.

This was in VC++ 2010

FYI
You need to add 3 txt files called player1.txt, player2.txt, player3.txt for it to work

//#include "mainscreen.h"
#include <string>
#include <conio.h>
#include <fstream>
#include <iostream>
#include <iomanip>
//#include "Card Index.h"

int ref();
int write(int & nav, int & limit);

//void setup(int & new1, int & new2, int & new3, int & nav)
void setup()
{
	int level = 0;
	int new1 = 0;
	int new2 = 0;
	int new3 = 0;
	int nav = 1;

	int limit = 0;
	if (new1 == 0 || new2 == 0 || new3 == 0)
	{
	ref();	
	//SetColor(YELLOW);
	cout << "Welcome to the new player screen! Press any key to begin:";
	while(1)
	{
		if(_kbhit())
		{
			_getch();
			break;
		}
	}
	ref();
	//SetColor(YELLOW);
	cout << "Enter your characters name (Max displayed will be 10): ";
	limit = 10;
	write(nav, limit);
	ref();
	system("cls");
	
	}

	else
		//PreBattle(deckBackup, 65, level);
	return;
}

int ref()
{

	system("cls");
	for (int i = 0; i < 80; i++)
	{
		//SetColor(RED);
		cout << "#";
	}
		for (int i = 0; i < 21; i++)
	{
		//SetColor(RED);
		cout << "#";
		//SetColor(DARKRED);
		cout << "Player Setup Player Setup Player Setup Player Setup Player Setup Player Setup ";
		//SetColor(RED);
		cout << "#";
	}

	for (int i = 0; i < 80; i++)
	{
		//SetColor(RED);
		cout << "#";
	}
	return 0;
}

int write(int & nav, int & limit, int & level, int & new1, int & new2, int & new3)
{
	string pas;
	pas = " ";
	//classa = selectclass();
	if (new1 == 0)
		level = 0;
	if (new2 == 0)
		level = 0;
	if (new3 == 0)
		level = 0;
	string temp;
	if (nav == 1)
	{
		cin >> temp;
		temp.resize(10,' ');
		pas.resize(5,' ');


		ofstream in1("player1.txt");
		if(!in1) 
		{
			cout << "Cannot open player file.\n";
			exit(0);
		}
		in1 << level + 15 << endl;
		in1 << temp << endl;
		in1 << pas << endl;

		in1.close();
	}

	if (nav == 2)
	{
		cin >> temp;
		temp.resize(10,' ');
		pas.resize(5,' ');

		ofstream in2("player2.txt");
		if(!in2) 
		{
			cout << "Cannot open player file.\n";
			exit(0);
		}

		in2 << level + 15 << endl;
		in2 << temp << endl;
		in2 << pas << endl;
		in2.close();
	}

	if (nav == 3)
	{
		cin >> temp;
		temp.resize(10,' ');
		pas.resize(5,' ');

		ofstream in3("player3.txt");

		if(!in3) 
		{
			cout << "Cannot open player file.\n";
			exit(0);
		}

		in3 << level + 15 << endl;
		in3 << temp << endl;
		in3 << pas << endl;
		in3.close();
	}
	return 0;
}

Recommended Answers

All 2 Replies

You don't have a main function...

lol, that would do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.