Why does printf output characters instead of data? Looking at the code, you can relatively understand what I want to do, but it is unclear why the output is like this
#include <vector>
#include <string>
#include <cstdio>
class Person
{
public:
Person(const std::string& name, uint16_t old)
: m_Name(name)
, m_Old(old)
{
}
public:
std::string GetName() const { return m_Name; }
uint16_t GetOld() const { return m_Old; }
private:
std::string m_Name;
uint16_t m_Old;
};
int main()
{
std::vector<Person> person = { Person("Kyle", 26), Person("Max", 20), Person("Josiah", 31) };
for (uint16_t i = 0; i < person.size(); ++i)
{
printf("Name: %s Old: %u\n", person[i].GetName(), person[i].GetOld());
}
return 0;
}
> // output
> Name: Ь·╣ Old: 1701607755
> Name: Ь·╣ Old: 7889229
> Name: Ь·╣ Old: 1769172810