Witam. Mam problem z jednym programem, który jest częścią tuto riala xiona "Od zera do gier kodera"
oto kod :
#include <string>
#include <iostream>
#include <conio.h>
using namespace std;
unsigned ZliczZnaki(std::string strTekst, char chZnak)
{
unsigned uIlosc = 0;
for (unsigned i = 0; i <= strTekst.length() - 1; ++i)
{
if (strTekst[i] == chZnak)
++uIlosc;
}
return uIlosc;
}
void main()
{
string strNapis;
cout << "Podaj tekst, w ktorym maja byc zliczane znaki: ";
cin >> strNapis;
char chSzukanyZnak;
cout << "Podaj znak, ktory bedzie liczony: ";
cin >> chSzukanyZnak;
cout << "Znak '" << chSzukanyZnak <<"' wystepuje w tekscie " << ZliczZnaki(strNapis, chSzukanyZnak) << " raz(y)." << endl;
getch();
}
Występujące błędy :
1>------ Build started: Project: lekcja15, Configuration: Debug Win32 ------
1> maine.cpp
1>c:\users\grzegorz\documents\visual studio 2010\projects\lekcja15\lekcja15\maine.cpp(57): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.
1> d:\program files\microsoft visual studio 10.0\vc\include\conio.h(128) : see declaration of 'getch'
1>maine.obj : error LNK2005: "unsigned int __cdecl ZliczZnaki(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,char)" (?ZliczZnaki@@YAIV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@D@Z) already defined in main.obj
1>maine.obj : error LNK2005: _main already defined in main.obj
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Grzegorz\documents\visual studio 2010\Projects\lekcja15\Debug\lekcja15.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Dodam jeszcze tylko że program jest pisany w Microsoft Visual C++ w wersji expres.
Proszę o szybka pomoc