Needar hjälp c++
Hej jag är hyffsat ny med c++, så jag hoppas ni förstår om detta är ett nybörjar misstag.
iallafall. jag försöker göra ett program som gör ett account genom att du skriver in din första bokstav i ditt för namn sen din första bokstav i ditt andra namn. och utav det så ska man få ut ett account som ser ut ungefär såhär: EX. "JA_8937"
JA står för Jesper Andersson, 8 får man pga att man använde "J" och 9 av "A". och de sista 2 siffrorna ska vara random.
jag är dock inte klar med mitt script. men jag har stött på ett problem som jag inte fattar.
här är min kod:
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
char first = 'a';
char second = 'b';
int third = 0;
int fourth = 0;
void calc(char first, char second);
while(true)
{
cout << "Enter the first letter in your FIRST name than press Enter, Repeat twice: " << endl;
cin >> calc(first, second);
cout << endl;
cout << "Now enter the first letter in your SECOND name, and then press Enter, " << endl << "repeat twice: " << endl;
cin >> calc(first, second);
cout << endl;
}
}
void calc(char first, char second)
{
char first2 = 'a';
char second2 = 'b';
int third = 0;
int fourth = 0;
int antal = 0;
if( first == 'A' || first == 'B' || first == 'C' || first == 'D')
{
if (antal == 0)
{
third = third +9;
}
else
{
fourth = fourth +9;
}
}
else if( first == 'E' || first == 'F' || first == 'G' || first == 'H')
{
if (antal == 0)
{
third = third +7;
}
else
{
fourth = fourth +7;
}
}
else if( first == 'I' || first == 'J' || first == 'K' || first == 'L')
{
if (antal == 0)
{
third = third +8;
}
else
{
fourth = fourth +8;
}
}
else if( first == 'M' || first == 'N' || first == 'O' || first == 'P')
{
if (antal == 0)
{
third = third +6;
}
else
{
fourth = fourth +6;
}
}
else if( first == 'Q' || first == 'R' || first == 'S' || first == 'T')
{
if (antal == 0)
{
third = third +4;
}
else
{
fourth = fourth +4;
}
}
else if( first == 'U' || first == 'V' || first == 'W' || first == 'X')
{
if (antal == 0)
{
third = third +5;
}
else
{
fourth = fourth +5;
}
}
else if( first == 'Y' || first == 'Z' )
{
if (antal == 0)
{
third = third +3;
}
else
{
fourth = fourth +3;
}
}
else
{
cout << "Only capital letters!" << endl << endl;
}
antal = antal + 1;
}
när jag deebuggar detta så får jag 2 errors:
.\acc.cpp(20) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\istream(1144): could be 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &,signed char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\istream(1146): or 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &,signed char &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
fast det fortsätter en bra bit med näst intill samma text