判断条件莫名无法执行
我想导入代码,但是确实无法从linux上导出,很抱歉。这是在liunx上运行的,始终无法成功让out值按照我判断条件输出。
随后,我在codeblock上,写了简易的代码,但是结果成功运行。
有没有人能够帮我看下原因啊,非常感谢。
程序代码:
#include <stdio.h> #include "string.h" char *Kcode(char *pin,int *prd); char *B5code(char *pdin5,int *prd); char *B3code(char *pdin3,char *pdin5,int *prd); char *Kcode(char *kcode,int *prd) { char *out="0000000000"; if(*prd == -1) { printf("initial kcode is %s\n",kcode); printf("initial *prd is %d\n",*prd); if(strcmp(kcode,"00011100")==0) { out ="0011110100"; *prd = -1; } if(strcmp(kcode,"00111100")==0) { out ="0011111001"; *prd = -1; } printf("out is %s\n",out); return out; } } int main() { char in[100]="00011100"; int rd=-1; int *prd=&rd; int z=1; char din5[]="00000"; char din3[]="000"; char *pdin5="01010"; char *pdin3="010"; char *out_6b="000000"; char *out_4b="0000"; char *out="0000000000"; char *ptin; ptin=in; char temp[10]; char dout[20]; // input file FILE *fp1=fopen("input.txt","r"); if(fp1 == NULL) { printf("cant find input file"); return 0; } fgets(in,11,fp1); printf("input is %s\n",in); if(z==1){ out=Kcode(ptin,&rd); } /* else if(z==0){ for(int i=0;i<3;i++) { din3[i]=in[i]; } printf("din3 is %s\n",din3); pdin3=din3; printf("pdin3 is %s\n",pdin3); pdin5=&in[3]; printf("pdin5 is %s\n",pdin5); out_6b=B5code(pdin5,&rd); printf("out_6b is %s\n",out_6b); out_4b=B3code(pdin3,pdin5,&rd); printf("out_4b is %s\n",out_4b); strcpy(dout,out_6b); strcpy(temp,out_4b); strcat(dout,temp); printf("final out is %s\n",dout); } else printf("cant recognize the code"); */ return 0; }