小编mat*_*ian的帖子

“不兼容的整数到指针转换”

由于这些错误,以下程序拒绝编译:

vigenere.c:52:31: error: incompatible integer to pointer conversion assigning to
  'string' (aka 'char *') from 'int' [-Werror,-Wint-conversion]
  ...ciphertext[i] = ((((plaintext[i] - 65) + keyword[num % keylength]) % 26) + 65);
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vigenere.c:56:31: error: incompatible integer to pointer conversion assigning to
  'string' (aka 'char *') from 'int' [-Werror,-Wint-conversion]
  ...ciphertext[i] = ((((plaintext[i] - 97) + keyword[num % keylength]) % 26) + 97);
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)

这是程序,旨在实现一个简单的 vigenere 密码:

#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>

int main(int argc, string argv[])
{ …
Run Code Online (Sandbox Code Playgroud)

c pointers compiler-errors incompatibletypeerror cs50

1
推荐指数
1
解决办法
1万
查看次数