mercredi 10 février 2021

How can I convert a string of characters to multiple int values? C++

I'm working on homework and the professor wants us to make this function. I'm having trouble understanding how to create it. This is the code I have modified several times. I have tried storing the string in array, or char array. And I tried using pointers. Below is a picture of the homework and my code I currently have.

Homework Function

    int valueOf(char a) {
        string alphabet = "abcdefghijklmnopqrstuvwxyz";
        string* ptr = &alphabet;

        alphabet[1] = 10; 

        if (a >= 0 && a <= 9) {
            return a;
        }else if(a == alphabet.){
        

        }
    }

Aucun commentaire:

Enregistrer un commentaire