| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 652 人关注过本帖
标题:密码问题,vc下很多BUG
只看楼主 加入收藏
校园浪子
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-7-22
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
密码问题,vc下很多BUG
#include<stdio.h>
#include<string.h>
file*fi;
main()
{char xu,a,xx[1000],mm[100],out[100][100];
int i,j,k,n,mylen,b[100];
for(i=0;i<100;i++)
for(j=0;j<100;j++)
out[i][j]=1;
if(fi=fopen("in.dat","r")==null)
{printf("can open int.dat\n");exit(1);}
i=0;
a=fgetc(fi);
while(a!=EOF)
{xx[i]=a;
i++;
a=fgetc(fi);
}
xx[i]='\0';
fclose(fi);
if(fi=fopen("miyao.dat","r")==null)
{printf("can open int.dat\n");exit(1);}
i=0;
a=fgetc(fi);
while(a!=EOF)
{mm[i]=a;
i++;
a=fgetc(fi);
}
fi='\0';
fclose(fi);
for(i=0;i<1000&&xx[i]!='\0';i++)
if(xx[i]>='a'&&xx[i]<='z')
xx[i]=xx[i]-32;
for(j=0;j<1000&&xx[j]!='\0';j++)
if(xx[i]<=65)
xx[j]=xx[j+1];
k=0;mylen=strlen(mm);
for(i=0;i<100&&xx[i]!='\0';i++)
for(j=0;j<=mylen;j++)
out[i][j]=xx[k];
for(j=0;j<100;j++)
{xu=mm[j];
k=0;
for(;j<100&&mm[j]!='\0';j++)
{if(xu>mm[j])
{xu=mm[j];
k=j;}}
mm[k]=127;
b[k]=i;}
b[i]=1000;
encrypt (mylen,b,out);
}
void encrypt (int mylen,int *b,char *out);
FILE*fi;
{int i,j,k,n;
if((fi=open("out.dat","w"))==null
{printf("out.dat error");exit(1);}
for(j=0;j<=mylen;j++)
{n=b[0];
for(k=0;k<mylen;k++)
if(n>b[k])
{n=b[k];i=k;}
k=i;b[k]=127;
for(i=0;i<100&&out[i][j]>1;i++)
{fput(out[i][j],fi);
printf("%c",out[i][j]);}}
fclose(fi);
}
搜索更多相关主题的帖子: BUG 密码 
2010-08-17 10:57
校园浪子
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-7-22
收藏
得分:0 
error C2664: 'fgetc' : cannot convert parameter 1 from 'int *' to 'struct _iobuf *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
f:\msdev98\myprojects\as\main.cpp(28) : error C2664: 'fgetc' : cannot convert parameter 1 from 'int *' to 'struct _iobuf *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
f:\msdev98\myprojects\as\main.cpp(31) : error C2664: 'fclose' : cannot convert parameter 1 from 'int *' to 'struct _iobuf *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
f:\msdev98\myprojects\as\main.cpp(52) : error C2065: 'encrypt' : undeclared identifier
f:\msdev98\myprojects\as\main.cpp(53) : warning C4508: 'main' : function should return a value; 'void' return type assumed
f:\msdev98\myprojects\as\main.cpp(54) : error C2373: 'encrypt' : redefinition; different type modifiers
f:\msdev98\myprojects\as\main.cpp(55) : error C2371: 'fi' : redefinition; different basic types
        f:\msdev98\myprojects\as\main.cpp(3) : see declaration of 'fi'
f:\msdev98\myprojects\as\main.cpp(56) : error C2447: missing function header (old-style formal list
2010-08-17 11:00
mxs810
Rank: 9Rank: 9Rank: 9
来 自:火星
等 级:贵宾
威 望:16
帖 子:234
专家分:1122
注 册:2006-10-19
收藏
得分:20 
程序代码:
#include<stdio.h>
#include<string.h>
//file*fi;
FILE*fi;

void encrypt (int mylen,int *b,char *out)
{
    FILE*fi;
    int i,j,k,n;
    //if((fi=open("out.dat","w"))==null
    if((fi=fopen("out.dat","w"))==NULL)
    {
        printf("out.dat error");
        //exit(1);
        return;
    }
    for(j=0;j<=mylen;j++)
    {n=b[0];
    for(k=0;k<mylen;k++)
    if(n>b[k])
    {n=b[k];i=k;}
    k=i;b[k]=127;
    for(i=0;i<100&&out[i][j]>1;i++)
    {fputs(out[i][j],fi);
    printf("%c",out[i][j]);}}
    fclose(fi);
}


//main()
int main()
{char xu,a,xx[1000],mm[100],out[100][100];
int i,j,k,n,mylen,b[100];
for(i=0;i<100;i++)
for(j=0;j<100;j++)
out[i][j]=1;
//if(fi=fopen("in.dat","r")==NULL)
if((fi = fopen("in.dat","r"))==NULL)
{
    printf("can open int.dat\n");
    //exit(1);
    return 1;
}
i=0;
a=fgetc(fi);
while(a!=EOF)
{xx[i]=a;
i++;
a=fgetc(fi);
}
xx[i]='\0';
fclose(fi);
//if(fi=fopen("miyao.dat","r")==null)
if((fi=fopen("miyao.dat","r"))==NULL)
{
    printf("can open int.dat\n");
    //    exit(1);
    return 1;
}
i=0;
a=fgetc(fi);
while(a!=EOF)
{mm[i]=a;
i++;
a=fgetc(fi);
}
fi='\0';
fclose(fi);
for(i=0;i<1000&&xx[i]!='\0';i++)
if(xx[i]>='a'&&xx[i]<='z')
xx[i]=xx[i]-32;
for(j=0;j<1000&&xx[j]!='\0';j++)
if(xx[i]<=65)
xx[j]=xx[j+1];
k=0;mylen=strlen(mm);
for(i=0;i<100&&xx[i]!='\0';i++)
for(j=0;j<=mylen;j++)
out[i][j]=xx[k];
for(j=0;j<100;j++)
{xu=mm[j];
k=0;
for(;j<100&&mm[j]!='\0';j++)
{if(xu>mm[j])
{xu=mm[j];
k=j;}}
mm[k]=127;
b[k]=i;}
b[i]=1000;
encrypt (mylen,b,out);
} 

给你改了一点,你先把你的代码规范好了,然后再检查代码的问题~~
祝你好运~~

授人以鱼不如授人以渔
2010-08-17 11:16
快速回复:密码问题,vc下很多BUG
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018047 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved