gpt4 book ai didi

c - 如何解释 GDB 中的断点?

转载 作者:太空宇宙 更新时间:2023-11-04 05:35:49 25 4
gpt4 key购买 nike

<分区>

我的代码

#include <stdlib.h>
#include <stdio.h>

int main()
{
int i=0;
int j=0;
size_t count=0;
float numbers[20][100];
float velocity[21][101];
char *line = NULL;

FILE *myFile;
myFile = fopen("vel.txt", "r");

if (myFile == NULL)
{
printf("Error Reading File\n");
exit (0);
}

while(i < 20 && getline(&line, &count, myFile)!=-1) {
int len = 0, pos = 0;
j = 0;
while(j < 100 && 1 == sscanf(line + pos, "%f%n", &numbers[i][j++], &len))
pos += len;
i++;
}
free(line);
fclose(myFile);

for( i = 0; i < 21; i++ )
for( j = 0; j < 101; j++ )
{
if( i= 1 && j == 1 )
{
velocity[i][j]=numbers[i][j];
}
else if ( i= 1 && j == 101 )
{
velocity[i][j]=numbers[i][j];
}
else if ( i=1 && j >= 2 && j <= 100)
{
velocity[i][j]=(numbers[i][j-1]+numbers[i][j])/2;
}
else if(i >= 2 && i <= 20 && j == 1)
{
velocity[i][j]=(numbers[i-1][j]+numbers[i][j])/2;
}
else if(i >= 2 && i <= 20 && j == 101)
{
velocity[i][j]=(numbers[i-1][j]+numbers[i][j])/2;
}
else if(i >= 2 && i <= 20 && j >= 2 && j <= 100) //means i goes from 2,20 j goes from 2,100
{
velocity[i][j]=(numbers[i-1][j]+numbers[i][j]+numbers[i][j]+numbers[i][j])/4;
}
else if( i= 21 && j == 1 )
{
velocity[i][j]=numbers[i][j];
}
else if ( i=21 && j >= 2 && j <= 100)
{
velocity[i][j]=(numbers[i][j-1]+numbers[i][j])/2;
}
else
{
velocity[i][j]=numbers[i][j];
}
}

return 0;
}

我可以用 gcc 编译它,但是 exe 永远运行。所以出了点问题。我尝试像这样调试

Breakpoint 1, main () at a1.c:11
11 char *line = NULL;
(gdb) c
Continuing.

Breakpoint 2, main () at a1.c:35
35 if( i= 1 && j == 1 )
(gdb) c
Continuing.

Breakpoint 2, main () at a1.c:35
35 if( i= 1 && j == 1 )
(gdb) c
Continuing.

Breakpoint 2, main () at a1.c:35
35 if( i= 1 && j == 1 )
(gdb) n
39 else if ( i= 1 && j == 101 )

但我是新手,这个断点告诉我什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com