| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1308 人关注过本帖
标题:在vc上运行时出现了Access Violation的错误。
只看楼主 加入收藏
月晕而风
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-11-11
收藏
 问题点数:0 回复次数:1 
在vc上运行时出现了Access Violation的错误。
我用c编了一个条形码识别的程序,但是在vc上运行时,刚用scanf输完13个字符后就出现了unhandled exception in EAN13.exe:0xC0000005:Access Violation的错误,请教一下是哪里出错了?下面是我的程序。
#include <string.h>
#include <stdio.h>
main()
{
int j,k,sum=0;
unsigned int i;
char *str,(*p)[7],num[14];
char dataA[10][7]={{'0','0','0','1','1','0','1'},{'0','0','1','1','0','0','1'},{'0','0','1','0','0','1','1'},
{'0','1','1','1','1','0','1'},{'0','1','0','0','0','1','1'},{'0','1','1','0','0','0','1'},
{'0','1','0','1','1','1','1'},{'0','1','1','0','1','1','1'},{'0','1','1','1','0','1','1'},
{'0','0','0','1','0','1','1'}};
char dataB[10][7]={{'0','1','0','0','1','1','1'},{'0','1','1','0','0','1','1'},{'0','0','1','1','0','1','1'},
{'0','1','0','0','0','0','1'},{'0','0','1','1','1','0','1'},{'0','1','1','1','0','0','1'},
{'0','0','0','0','1','0','1'},{'0','0','1','0','0','0','1'},{'0','0','0','1','0','0','1'},
{'0','0','1','0','1','1','1'}};
char dataC[10][7]={{'1','1','1','0','0','1','0'},{'1','1','0','0','1','1','0'},{'1','1','0','1','1','0','0'},
{'1','0','0','0','0','1','0'},{'1','0','1','1','1','0','0'},{'1','0','0','1','1','1','0'},
{'1','0','1','0','0','0','0'},{'1','0','0','0','1','0','0'},{'1','0','0','1','0','0','0'},
{'1','1','1','0','1','0','0'}};
char dataAB[10][6]={{'A','A','A','A','A','A'},{'A','A','B','A','B','B'},{'A','A','B','B','A','B'},
{'A','A','B','B','B','A'},{'A','B','A','A','B','B'},{'A','B','B','A','A','B'},
{'A','B','B','B','A','A'},{'A','B','A','B','A','B'},{'A','B','A','B','B','A'},
{'A','B','B','A','B','A'}};

do
{
printf("input 13 numbers:"); /*input bar code*/
for (i=1;i<14;i++)
scanf("%c",&num[i]);
for(i=2;i<13;i+=2) /*parity bit inspect*/
sum=sum+num[i]-48;
/*num[i]-48: string0=number0+48 (ascii) */
sum=sum*3;
for(i=1;i<13;i+=2)
sum=sum+num[i]-48;
k=10-sum%10;
if (k!=num[13]-48) printf("there is an error in parity bit!\n");
}
while(k!=num[13]-48);

str= "000000000101"; /*paint bar code*/
for(i=2;i<=7;i++)
{
for(j=0;j<6;j++)
{
if(dataAB[num[1]-48-1][j]=='A') p=dataA;
else p=dataB;
for(k=0;k<7;k++)
{
strcat (str,*(p+num[i]-48-1)+k);
}
}
}
strcat (str,"01010");
for(i=8;i<=13;i++)
{
for(j=0;j<6;j++)
{
p=dataC;
for(k=0;k<7;k++)
{
strcat (str,*(p+num[i]-48-1)+k);
}
}
}
strcat (str,"101000000000");

for(i=0;i<= strlen(str);i++) /*print bar code*/
{
if(str[i]=='1') printf("|");
else printf(" ");
}
printf("\n");
}
搜索更多相关主题的帖子: Violation Access 运行 
2008-11-11 14:50
月晕而风
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-11-11
收藏
得分:0 
下面是条形码识别原理

条形码产生和识别.rar (12.43 KB)
2008-11-11 15:15
快速回复:在vc上运行时出现了Access Violation的错误。
数据加载中...
 
   



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

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