とCのcharを印刷:私はそれを実行するとは、私は次のコードを持っているのprintf文句を言わない印刷
#include <stdio.h>
#include <string.h>
int main(void)
{
char buff[50];
int pass = 0;
printf("\n Enter the password : \n");
gets(buff);
char str[80];
strcat(str, "nw");
strcat(str, "ww");
strcat(str, "io");
strcat(str, "oi");
char str2[22];
strcat(str2, "jm");
strcat(str2, "qw");
strcat(str2, "ef");
strcat(str2, "io");
strcat(str2, "nw");
strcat(str2, "ce");
strcat(str2, "or");
strcat(str2, "ww");
strcat(str2, "qf");
strcat(str2, "ej");
strcat(str2, "oi");
if(strcmp(buff, str))
{
/* we sf as df er fd xc yyu er we nm hj ui ty as asd qwe er t yu as sd df rt ty qw sd password */
printf ("\n Wrong Password \n");
}
else
{
printf ("\n Correct Password \n");
pass = 1;
}
if(pass)
{
printf ("\n\n\n\n\n\n\n%s", str2);
}
return 0;
}
を私が取得:
[email protected]:~# ./root.flag
Enter the password :
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Wrong Password
Segmentation fault (core dumped)
それは価値ストア改行文字を出力しますが、ありませんstr2。 str2をスクリーンに印刷するにはどうすればいいですか?私はまったく新しいC言語なので、なぜこれが動かないのか分かりません。私が見落としていることは簡単かもしれません。
あなたのコードには '%c'変換タイプ指定子がありません。 – Olaf