vba c语言 java_“Abort trap:6”在Mac上运行C程序

我有这个程序的问题 . 当我尝试在Mac上运行它时,它会返回“Abort trap:6” . 我无法理解原因 .

下面是我用来测试程序的文件内容 .

aaabccdegags bbbbbbbcados vbaiusbyabtd aisybavsitvc asindvsivati ammaccabanan

您应该将这些无意义的字符串复制到文本文件 file.txt 中,并使用以下语法通过命令提示符调用它:

program.exe file.txt r

其中 file.txt 包含无意义字符串, r 是它应在文本文件中查找的字母 .

#include

#include

#include

#include

#define R 24

#define C 71

int main(int argc, char * argv[]) {

if (argc!=3){

printf("Errore acquisizione parametri\n");

return -1;

}

FILE*fp;

char m[R][C],c,posizione[10];

int i,j,lstr,numrighe,quante,quantemax,posiz,x,y,maxmax;

maxmax=0;

//posiz=1 se orizzontale

quantemax=0;

sscanf(argv[2],"%c",&c);

fp=fopen(argv[1],"r");

if (fp==NULL){

printf("Errore apertura file\n");

return -3;

}

for (i=0;i

fgets(m[i],C,fp);

}

fclose(fp);

lstr=strlen(m[0]);

numrighe=i;

for (i=0;i

quante=0;

for (j=0;j

if (m[i][j]==m[i][j+1]){

quante++;

if (quante>quantemax){

quantemax=quante;

if (quantemax>maxmax){

y=i;

x=j;

posiz=1;

}

}

}

}

}

for (i=0;i

quante=0;

for (j=0;j

if (m[i][j]==m[i+1][j]){

quante++;

if (quante>quantemax){

quantemax=quante;

if (quantemax>maxmax){

y=i;

x=j;

posiz=0;

}

}

}

}

}

if (posiz==1){

strcpy(posizione,"orizzontale");

}

else {

if (posiz==0){

strcpy(posizione,"verticale");

}

}

printf("La stringa con il maggior numero di %c consecutive, si trova in %s a partire dalla posizione %d,%d",c,posizione,x,y);

return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值