我需要帮助将 unsigned int 或字符串转换为 char 或 ASCII 整数。我无法访问我的 switch case 语句,因为令牌值的解释不正确。我的起始数据类型是一个字符串,取自队列。
令牌是整数类型,但不被视为 ASCII。我查看了从字符串到 ASCII 或字符串到 Char 的转换,但我对如何实现它感到困惑:所有定义都硬编码了一个字符串 Char[] = "string"; 虽然我需要通过引用传递一个字符串。
while (queueObj.IsEmpty() == false) // While the queue has nodes
{
string queueString = queueObj.head->dataQueue; // Get data from Queue node
int token = std::stoul(queueString); // Converts string data to integer value
switch (token) // compares the value of the queue data for stack operation
{
case '+':
{
// switch case operations
}