私は入力された文字列を取り込み、文字を整数に変換する必要があります(a = 1、b = 2、c = 3等)を求めて出力する。個々の文字を基本的なパスワードハッシャーの整数に変換する方法C++
これまで私が持っていたのは、整数に変換する文字列を使用するintを返す関数です。しかし、私はすでにこれを構築しようとしている間にいくつかのエラーに遭遇しています。文字の変換に関してここからどのように進めるか分かりません。
#include <iostream>
#include <string>
#include <windows.h>
#include <conio.h>
using namespace std;
int passHasher(string tempPassword)
{
int hashValue = 0; //function will return this at the end of the passes.
for (int i = 0; i < tempPassword.size; i++)
{
//hashing algorythm goes here.
}
}
乾杯、
オーウェン。
int char_value = tempPassword [i] - 'a' + 1 – Meccano
文字には[数値](http://www.asciitable.com/)が含まれています。たとえば、 'tempPassword [i] - 'a''は' tempPassword'の各文字の 'a'からのオフセットを与えます。 –
_But私はすでに、いくつかのエラーを越えて、これを構築しようとしています。あなたはエラーメッセージを含めませんでした。なぜですか? –