我用C - FREE 3。5 写C程序~
但是经常出现一写 莫名其妙的问题~
如 : 我写了一段程序!
pw_stmp = "123456" ;
mn_stmp = "88888880000001" ;
int i_yz ; // 显示这行错误!!不知道为什么 我声明一个INT型的变量也错!
编译 的时候 指出我 第三行 错误~ 错误信息:parse error before 'int'
----------------解决方案--------------------------------------------------------
高手指点以下
----------------解决方案--------------------------------------------------------
全部代码
----------------解决方案--------------------------------------------------------
#include <string.h>
#include <stdio.h>
char * substring(char *str1,char *str2,int a,int b);
char * stryz(char *bjvalue , char *stmp) ;
char * answer( char *answer_st , char *answer_cn , char *answer_pw , char *answer_mn ,char *answer_Flag , char *answer_qn , char *answer_cp) ;
char *send( char *send_st , char *send_cn , char *send_pw , char *send_mn , char *send_cp ) ;
int main( )
{
char s[110]="QN=20040516010101001;ST=32;CN=1072;PW=123456;MN=88888880000001;Flag=3;CP=&&PW=654321123456&&";
char *p=s;
char *s1=s;
char *v1 ;
char *pw_stmp ;
char *mn_stmp ;
char *stmp ;
char qn[18] ;
char st[6] ;
char cn[6] ;
char pw[20] ;
char mn[18] ;
char *mn1;
char Flag[3] ;
char cp[20] ;
char pw_set[10] ;
int isp ;
int iep ;
char answer_qq[90] ;
char send_temp[100] ;
isp = 0 ;
/*==========检测数据包的完整性==========*/
if ((strchr(s,'Q')-s) < 0 || (strchr(s,'N')-s) < 0 || (strchr(s,'S')-s) < 0 || (strchr(s,'T')-s) < 0
||(strchr(s,'C')-s) < 0 || (strchr(s,'P')-s) < 0 || (strchr(s,'W')-s) < 0 || (strchr(s,'M')-s) < 0
|| (strchr(s,'P')-s) < 0 || (strchr(s,'&')-s) < 0 )
{
printf("异常:%s\n","数据包格式错误!!程序不做处理!!") ;
}
else
{
printf("正常:%s\n","数据包格式正常") ;
}
/*******取QN***************/
p=strchr(s,'=') ;
isp = p-s ;
p++;
p=strchr(p,';') ;
iep = p-s ;
substring(v1,s1,isp+2,iep-(isp+1)) ; //这里调用函数:FUN
strcpy(qn, v1);
printf("QN:%s\n",qn);
/********取ST************/
p = strchr(p,'=') ;
isp = p-s ;
p = strchr(p,';') ;
iep = p-s ;
substring(v1,s1,isp+2,iep-(isp+1));
strcpy(st, v1);
printf("ST:%s\n",st) ;
/********取CN************/
p = strchr(p,'=') ;
isp = p-s ;
p = strchr(p,';') ;
iep = p-s ;
substring(v1,s1,isp+2,iep-(isp+1));
strcpy(cn, v1);
printf("CN:%s\n",cn) ;
/********取PW************/
p = strchr(p,'=') ;
isp = p-s ;
p = strchr(p,';') ;
iep = p-s ;
substring(v1,s1,isp+2,iep-(isp+1));
strcpy(pw, v1);
printf("PW:%s\n",pw) ;
/********取MN************/
p = strchr(p,'=') ;
isp = p-s ;
p = strchr(p,';') ;
iep = p-s ;
substring(v1,s1,isp+2,iep-(isp+1));
strcpy(mn, v1);
printf("MN:%s\n",mn) ;
/********取Flag************/
p = strchr(p,'=') ;
isp = p-s ;
p = strchr(p,';') ;
iep = p-s ;
substring(v1,s1,isp+2,iep-(isp+1));
strcpy(Flag, v1);
/********取CP************/
p = strchr(p,'&') ;
isp = p-s ;
p = p+2 ;
p = strchr(p,'&') ;
iep = p-s ;
substring(v1,s1,isp+3,iep-(isp+2));
strcpy(cp, v1);
printf("CP:%s\n",cp) ;
/*- - - - - - 验 证 密 码 和 设 备 ID - - - - - - - - - - - - - - - - - - */
pw_stmp = "123456" ;
mn_stmp = "88888880000001" ;
int set_yz ; 这里出错!!
// i_yz = strcmp(pw_stmp,"123456") ;
}
/*------------------------------------------------------------------------------*/
/* */
/* /*函数区域*/
/* */
/*------------------------------------------------------------------------------*/
/******************函数(substring)******************************/
char * substring(char *str1,char *str2,int a,int b)
{
char *ptr1=str1;
long i ;
for(i=a;i<a+b;i++)
{
*ptr1=*(str2+i-1);
ptr1++ ;
}
*ptr1=0;
return str1;
}
/******************函数(stryz)******************************/
char * stryz(char *bjvalue , char *stmp)
{
int n = strcmp(bjvalue,stmp) ;
if( n != 0 )
{
printf("消息:%s\n","密码或者设备ID错误") ;
return "1" ;
}
else
{
printf("消息:%s\n","密码及设备ID正确") ;
return 0 ;
}
}
/******************函数(answer)******************************/
/*-------------------------*/
/*请求应答函数 */
/*------------------------*/
char * answer( char *answer_st , char *answer_cn , char *answer_pw , char *answer_mn ,char *answer_Flag , char *answer_qn , char *answer_cp)
{
char *answer_str ;
char answer_stmp[90] ;
strcpy(answer_stmp, "ST=");
strcat(answer_stmp,answer_st) ;
strcat(answer_stmp,";") ;
strcat(answer_stmp,"CN=") ;
strcat(answer_stmp,answer_cn) ;
strcat(answer_stmp,";") ;
strcat(answer_stmp,"PW=") ;
strcat(answer_stmp,answer_pw) ;
strcat(answer_stmp,";") ;
strcat(answer_stmp,"MN=") ;
strcat(answer_stmp,answer_mn) ;
strcat(answer_stmp,";") ;
strcat(answer_stmp,"Flag=") ;
strcat(answer_stmp,answer_Flag) ;
strcat(answer_stmp,";") ;
strcat(answer_stmp,"CP=&&QN=") ;
strcat(answer_stmp,answer_qn) ;
strcat(answer_stmp,";") ;
strcat(answer_stmp,answer_cp) ;
strcat(answer_stmp,"&&") ;
answer_str = answer_stmp ;
return answer_str ;
}
/*****************************函数(send)***************************************************/
char *send( char *send_st , char *send_cn , char *send_pw , char *send_mn , char *send_cp )
{
char *send_str ;
char send_stmp[90] ;
strcpy( send_stmp , "ST=" ) ;
strcat( send_stmp , send_st ) ;
strcat( send_stmp , ";" ) ;
strcat( send_stmp , "CN=" ) ;
strcat( send_stmp , send_cn ) ;
strcat( send_stmp , ";" ) ;
strcat( send_stmp , "PW=" ) ;
strcat( send_stmp , send_pw ) ;
strcat( send_stmp , ";" ) ;
strcat( send_stmp , "MN=" ) ;
strcat( send_stmp , send_mn ) ;
strcat( send_stmp , ";" ) ;
strcat( send_stmp , "CP=&&" ) ;
strcat( send_stmp , send_cp ) ;
strcat( send_stmp , "&&" ) ;
send_str = send_stmp ;
return send_str ;
}
----------------解决方案--------------------------------------------------------
C-FREE 没错误!
----------------解决方案--------------------------------------------------------
你的C - FREE 没错误吗??
----------------解决方案--------------------------------------------------------
为什么我的有错误??
----------------解决方案--------------------------------------------------------
后缀 .cpp
用C++文件存储!
----------------解决方案--------------------------------------------------------
你有C-FREE的注册机吗?
----------------解决方案--------------------------------------------------------
[CODE]#include "stdlib.h"
#include "stdio.h"
int main(int argc, char* argv[])
{
char chKey[128] = {0};
unsigned int unXORCode, unRemainder, unQuotient, unTmp, unMachineCode;
printf("Please Key in the Machine Code:\n");
scanf("%d", &unMachineCode);
unXORCode = unMachineCode ^ 0x90909090;
unRemainder = unXORCode % 0x25;
unQuotient = unXORCode;
if (unRemainder < 0x11)
{
unRemainder += 0x11;
}
int i;
i = 0;
while (unQuotient != 0)
{
unTmp = unQuotient % unRemainder;
unQuotient /= unRemainder;
if (unTmp >= 0xa)
{
unTmp = unTmp + 0x61 + 0xf6;
unTmp &= 0x0ff;
chKey[i] = unTmp;
}
else
{
chKey[i] = unTmp + 0x30;
}
i++;
}
printf("Key is: \n");
while (i >= 0)
{
printf("%c", chKey[i]);
i--;
}
printf("\n");
return 0;
}[/CODE]
老K刨开的吧
----------------解决方案--------------------------------------------------------