我有这两个char数组,它们在控制台(DESKTOP-KDOD9T)上输出相同的值,一个从文件中读取,另一个通过winsock gethostname接收。相比之下,它们并不相同。它说您无法访问该程序。
#!/bin/bash -e
# Note: it is a script to solve Ubuntu 18.04 LTS
# different version of pythons compiling
# header confliction problems
#
# The idea is got from @JustAnotherArivist
# From URL: https://github.com/pyenv/pyenv/issues/945
#
# The script used in here is with slightly modifications
# to fit many different SSL header versions
# First under your home directory make OpenSSL library
# and extract useful package
mkdir ~/libssl1.0-dev
cd ~/libssl1.0-dev
apt-get download libssl1.0-dev
ar x libssl1.0-dev* data.tar.xz
tar -xf data.tar.xz --strip-components=2
# Second, specifically get your current system's SSL headers
# and make symbolic-links
libcrypto=$(ls /usr/lib/x86_64-linux-gnu/ | grep libcrypto.so......)
libssl=$(ls /usr/lib/x86_64-linux-gnu/ | grep libssl.so......)
ln -s /usr/lib/x86_64-linux-gnu/${libcrypto} ~/libssl1.0-dev/lib/x86_64-linux-gnu
ln -s /usr/lib/x86_64-linux-gnu/${libssl} ~/libssl1.0-dev/lib/x86_64-linux-gnu
# Set your CFLAGS LDFLAGS compile options
# And use pyenv install the python version <3.4.5 or <3.5.3
# Note: it is a one line command
# Please change the version of python that you want to compile
CFLAGS="-I${HOME}/libssl1.0-dev/include -I${HOME}/libssl1.0-dev/include/x86_64-linux-gnu" \
LDFLAGS="-L${HOME}/libssl1.0-dev/lib/x86_64-linux-gnu" \
pyenv install 3.4.2
# Remove tempor libssl1.0-dev direcotory
rm -rf ~/libssl1.0-dev
答案 0 :(得分:2)
数组没有可以比较的值。它们包含多个值。
当您比较两个数组时,这些数组会衰减到指针,并且您正在比较指针以查看它们是否指向同一对象。当然,他们没有。
如果要比较每个字节,可以使用类似memcmp
的函数。如果要比较两个字符串,可以使用类似strcmp
的函数。