gpt4 book ai didi

c - 尝试递增字母时出现段错误

转载 作者:太空宇宙 更新时间:2023-11-04 04:22:40 25 4
gpt4 key购买 nike

<分区>

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

int main(int argc, string argv[])
{
if(argc > 2){ printf("too many arguments\n"); return 51; }
if(argc < 2){ printf("too few arguments\n"); return 50; }
if(strlen(argv[1]) > 4){ printf("Password is greater than 4 characters\n"); return 52; }

if(argc == 2) //make sure there are enough args
{
string hash_guess = "A";

while(crypt(hash_guess, "50") != argv[1]) //while answer not correct
{
while(hash_guess[0] <= 'Z' && hash_guess[0] >= 'A')
{
hash_guess[0] = hash_guess[0] + 1;
printf("%s", hash_guess);
}
}

}

}

我试图通过一个单词逐个字母递增,所以它会先是 a 然后是 b 然后是 c 直到 z 然后它会变成 aa、ab、ac、ad.... 然后 ba bb bc bd... 然后za...zz...zzz。我从一个字母开始,但出现错误“段错误”

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com