当Str1不包含Str2时,strcspn()的返回值是多少?(What Is the Return Value of strcspn() When Str1 Does not Contain Str2?)
我似乎无法在任何地方找到它,但当str1不包含str2时,strcspn()是否返回-1? 例如,说我有:
strcspn(argv[1], " ");
如果argv [1]不包含空格,函数是否会返回-1或其他内容?
I can't seem to find this anywhere, but does strcspn() return -1 when str1 does not contain str2? For example, say I have:
strcspn(argv[1], " ");
Will the function return -1 or something else if argv[1] does not contain a space?
原文:https://stackoverflow.com/questions/32390478
最满意答案
你需要做两件事,到目前为止你只做了一件事。
您需要告诉编译器在哪里找到适当的声明。 你已经完成了这个添加
#include "evp.h"
在您的源文件中。 (根据你安装crypto ++的方式,你可能还需要告诉编译器在哪里找到
"evp.h"
,可能使用-Isome_directory
。)您缺少的步骤是告诉链接器在哪里可以找到您正在使用的函数的实际实现(已编译的代码)。 根据发行版中包含的
Readme.txt
文件,bulding crypto ++创建了一个名为libcryptopp.a
的库文件。所以这样的事情应该做的工作:
gcc my_program.c -o my_program -lcryptopp
根据您安装它的方式和位置,您可能还需要指定
-Lsome_directory
来告诉链接器在哪里可以找到libcryptopp.a
。 (gcc
命令调用编译器和链接器。--l
选项告诉链接器使用libcryptopp.a
。如果需要,-L
选项告诉它要查找的目录。)You need to do two things, of which you've only done one so far.
You need to tell your compiler where to find the appropriate declarations. You've done this by adding
#include "evp.h"
in your source file. (Depending on how you installed crypto++, you might also need to tell the compiler where to find
"evp.h"
, probably using-Isome_directory
.)The step you're missing is telling the linker where to find the actual implementation (the compiled code) of the functions you're using. According to the
Readme.txt
file included in the distribution, bulding crypto++ creates a library file calledlibcryptopp.a
.So something like this should do the job:
gcc my_program.c -o my_program -lcryptopp
Depending on how and where you installed it, you might also need to specify
-Lsome_directory
to tell the linker where to findlibcryptopp.a
. (Thegcc
command invokes both the compiler and the linker. The-l
option tells the linker to uselibcryptopp.a
. The-L
option, if needed, tells it what directory to look in.)
相关问答
更多-
EVP_CIPHER_CTX_set_key_length接受河豚的不良大小(EVP_CIPHER_CTX_set_key_length accepts bad sizes for blowfish)[2023-04-20]
使用EVP_CIPHER_CTX_set_key_length()仅在密码具有可变密钥长度的情况下有用(Blowfish就是这种情况)。 该函数对提供的密钥长度进行了一些有限的验证。 如果密码具有固定长度的密钥,则它将检查所提供的密钥长度是否与固定长度相同。 否则它将返回错误。 如果使用带有可变长度密钥的密码,则只检查密钥长度是否为正。 否则,您可以设置任何您喜欢的值。 它确实没有什么区别,因为当Blowfish使用它时,它会检查密钥长度是否合理,如果太长则使用减少的长度: static int bf_in ... -
密码,如AES256和其他加密工具是libcrypto库的一部分; libssl主要关注SSL / TLS协议。 使用-lcrypto而不是-lssl3链接。 Ciphers, such as AES256, and other encryption utilities are part of the libcrypto library; libssl is primarily concerned with the SSL/TLS protocol. Link with -lcrypto instead o ...
-
OpenSSL链接未定义的引用'EVP_MD_CTX_new'和'... fre'(OpenSSL Linking undefined reference 'EVP_MD_CTX_new' and '…fre')[2024-04-12]
您好像使用旧版本的openssl(<1.1.0)。 也许您已下载并安装了较新版本,但您的链接器似乎找到并使用旧版本的openssl库。 1.1.0中的EVP_MD_CTX_create()已替换EVP_MD_CTX_create() 。 1.1.0中的EVP_MD_CTX_destroy()已替换EVP_MD_CTX_destroy() 。 您可能尝试使用这些函数的旧版本,或确保您的链接器确实使用了openssl库的> = 1.1.0版本。 You seem to be using an older ver ... -
您blackout打电话,然后再拨打init 。 init是它定义ctx 。 You call blackout first and than you call init second. init is where it defines ctx.
-
创建EVP_CIPHER_CTX数组(Create EVP_CIPHER_CTX array)[2023-08-22]
在我咨询了OpenSSL用户的电子邮件列表之后,我进行了下列修改,以便编译代码: #define AES_KEY_CTX *EVP_CIPHER_CTX; static void InitAESKey(AES_KEY_CTX* ctx, BYTE* keybytes, int numkeys) { BYTE* pBufIdx = keybytes; for (int i = 0; i < numkeys; i++) { EVP_CIPHER_CTX_init(*(ct ... -
EVP_CIPHER *来命名(EVP_CIPHER* to name)[2023-06-26]
请在这里查看EVP_CIPHER_name。 看,它能否解决你的目的。 Please look at EVP_CIPHER_name here. See, if it can solve your purpose. -
你需要做两件事,到目前为止你只做了一件事。 您需要告诉编译器在哪里找到适当的声明。 你已经完成了这个添加 #include "evp.h" 在您的源文件中。 (根据你安装crypto ++的方式,你可能还需要告诉编译器在哪里找到"evp.h" ,可能使用-Isome_directory 。) 您缺少的步骤是告诉链接器在哪里可以找到您正在使用的函数的实际实现(已编译的代码)。 根据发行版中包含的Readme.txt文件,bulding crypto ++创建了一个名为libcryptopp.a的库文件。 所 ...
-
似乎pyelliptic 1.5.8有一个bug 。 您可以通过降级到1.5.7来修复它: pip install pyelliptic==1.5.7 pyelliptic实际上已被弃用 ,所以如果你可以帮助它,请避免使用它。 尝试使用pip uninstall pyelliptic卸载它,然后通过运行pip check查看是否破坏了任何依赖项。 It seems that pyelliptic 1.5.8 has a bug. You might be able to fix it by downgra ...
-
不,你没有。 init函数EVP_CipherInit_ex实际上是在EVP_CIPHER_CTX对象ectx初始化变量,您将其作为第一个参数传递。 记得在完成后调用EVP_CIPHER_CTX_cleanup(&ectx) 。 No, you don't. The init function EVP_CipherInit_ex is actually initializing variables in EVP_CIPHER_CTX object ectx, which you pass as the fi ...
-
显然, EVP_DecryptInit_ex和EVP_EncryptInit_ex重新初始化上下文,因此在调用这些方法之后应该执行任何上下文更改(例如设置填充)。 Apparently both EVP_DecryptInit_ex and EVP_EncryptInit_ex re-initialize the context so any context changes (such as setting the padding) should be performed after those metho ...