用数组和字符串比较函数编写一程序.采用不回显方式输入两次6位密码,并判断两次输入的密码是否相符

来源:百度知道 编辑:UC知道 时间:2024/06/22 17:06:53
利用数组和字符串比较函数,编写一程序.采用不回显方式输入两次6位密码,并判断两次输入的密码是否相符
话说是要用到字符串来着
1楼的好象有挺多错误的``````````

我写的这个`````不知道哪里出错了!!请教高人了!
#include <stdio.h>
#include <conio.h>
#include <string.h>

void main ()
{
char a[7],b[7];
int i,j;
printf ("Please press the password:");
for(i=0;i<6;i++)
{
a[i]=getch();
printf ("*");

}
fflush(stdin);
printf ("\nPlease press the password again:");
for(i=0;i<6;i++)
{
b[i]=getch();
printf ("*");

}
for(i=0;i<6;i++)
{
if (strcmp (a[i],b[i])>0)
printf("\n两次的密码输入不相同\n");
else
printf ("\n密码设置成功!\n");
}
}

#include <stdio.h>
#include <conio.h>
#include <string.h>

void main ()
{
char a[7],b[7];
int i,j;
printf ("Please press the password:");
for(i=0;i<6;i++)
{
a[i]=getch();
printf ("*");

}
a[i] = '\0';
fflush(stdin);
printf ("\nPlease press the password again:");
for(i=0;i<6;i++)
{
b[i]=getch();
printf ("*");

}
b[i] = '\0';
if (strcmp (a,b))
printf("\n两次的密码输入不相同\n");
else
printf ("\n密码设置成功!\n");
}

#include "stdio.h"
#include "conio.h"
void main()
{
char pas[7];
int i;
bool correct=true;
printf("input password:");
for(i=0;i<6;i++)
pas[i]=getch();
pas[6]='\0';
printf("

C语言编程-用数组方法编写函数strcmp,比较两个字符串的大小。 编写两个字符串比较大小的函数和将字符串倒置的函数.用C++实现,给出源程序哦 编写函数实现C++库函数对字符串或数组的求解:strlen(char*)和strcat(char *,char *) 编写连接字符串函数。 请教该用什么函数输入二维字符串数组? 用C++编写一个函数,实现将输入的字符串逆序输出,字符串的输入和输出在main函数种实现。 用数组编写一个函数判断一个回文数---求救 用c++数组编写一个函数求元素中的最大值 统计一个子字符串在另一个字符串中出现的次数及位置(位置存储在数组中)。请编写函数实现。 c++编程 编写put()函数和get()函数,把值放入数组并取值