将char []转换为Int []

Bak*_*suf 0 c

我有一个这样的char数组:

char res[80]="00001111001010100100001010101100000010011100001000110010000101000100001010010001"
Run Code Online (Sandbox Code Playgroud)

想改变成

int res[80]=00001111001010100100001010101100000010011100001000110010000101000100001010010001
Run Code Online (Sandbox Code Playgroud)

做过这样的事情:

char res[80]="00001111001010100100001010101100000010011100001000110010000101000100001010010001";
int resInt[80];
for (int i = 0; i<80; i++) {
    resInt [i] = res[i];
    printf("%d",resInt[i]);
}
Run Code Online (Sandbox Code Playgroud)

结果是这样的:

4848484849494949484849484948494848494848484849484948494849494848484848484948484949494848484849484848494948484948484848494849484848494848484849484948484948484849
Run Code Online (Sandbox Code Playgroud)

谁能帮我??谢谢

Jam*_*oth 7

ASCII'0'实际上是标量形式的48,所以减去它:

resInt[i] = res[i] - '0';
Run Code Online (Sandbox Code Playgroud)