Hi.
I have this code:
// Osman Zakir
// 11 / 10 / 2021
// Beginning C++20: From Novice to Professional by Ivor Horton and Peter Van Weert
// Chapter 4 Exercise 7
// Exercise Specs:
/**
* Implement a program that prompts for the input of a letter. Use a library function
* to determine whether the letter is a vowel and whether it is lowercase or not, and output the
* result. Finally, output the lowercase letter together with its character code as a binary value. As
* a bonus exercise, you could try to do the latter without the use of std::format()?
*/
import <iostream>;
import <bitset>;
#include <cctype>
int main()
{
std::cout << "Enter a letter: ";
char letter{};
std::cin >> letter;
std::cin.ignore(32767, '\n');
const std::bitset<8> binary_letter{ static_cast<std::uint16_t>(std::tolower(letter)) };
if (std::isalpha(letter))
{
if (std::tolower(letter) == 'a' || std::tolower(letter) == 'e' ||
std::tolower(letter) == 'i' || std::tolower(letter) == 'o' ||
std::tolower(letter) == 'u')
{
std::cout << "Your letter is a vowel." << std::endl;
if (std::islower(letter))
{
std::cout << "It's lowercase, and in binary, it's " << binary_letter << std::endl;
}
}
else
{
std::cout << "Your letter is a consonant." << std::endl;
if (std::islower(letter))
{
std::cout << "It's lowercase, and in binary, it's " << binary_letter << std::endl;
}
}
}
}
I'm getting this linker error from it:
error LNK2019: unresolved external symbol "class std::ctype<char> const & __cdecl std::use_facet<class std::ctype<char> >(class std::locale const &)" (??$use_facet@V?$ctype@D@std@@@std@@YAABV?$ctype@D@0@ABVlocale@0@@Z) referenced >in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<char,struct >std::char_traits<char>,8>(class std::basic_ostream<char,struct std::char_traits<char> > &,class std::bitset<8> const &)" (??$?>6DU?$char_traits@D@std@@$07@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@Abv ?>$bitset@$07@0@@Z)
1>E:\programming\visual_studio_2019\Projects\beginningcpp20\chapter4ex7\Debug\chapter4ex7.exe : fatal error LNK1120: 1 >unresolved externals
1>Done building project "chapter4ex7.vcxproj" -- FAILED.
Trying to build it on godbolt shows that it should build, but I've already tried restarting VS2019 and cleaning and rebuilding it with no luck.