小编use*_*316的帖子

如何在C中删除以下lint警告?

我有以下代码:

#define NUM_DAYS 65
#define NUM_PERSON 33

int num = 0;

if(NUM_DAYS % NUM_PERSON)
{
    num = NUM_DAYS / NUM_PERSON;
}
else 
{
    uum = NUM_DAY / NUM_PERSON + 1;
}

num = num - 1;

while(num > 0)
{
    //do something here
}
Run Code Online (Sandbox Code Playgroud)

但是我得到了以下lint警告:

Warning 681: Loop is not entered
Run Code Online (Sandbox Code Playgroud)

问题是什么以及如何解决?

c loops lint

5
推荐指数
2
解决办法
712
查看次数

我们怎么知道这是数组中的最后一个元素?

我有以下代码:

int array[5] = {1, 0, 1, 0, 0};

int i;

for(i = 0; i < 5; i++)
{
   if(array[i] == 1)
   {
      printf("found one\n");
   }
}
Run Code Online (Sandbox Code Playgroud)

我们怎么会知道第二1array是最后1我们发现了什么?我不是说保持最后的价值1,我的意思是我们应该怎么知道第二次1是最后一次出现,再没有出现?

c arrays

4
推荐指数
1
解决办法
275
查看次数

如何检查/运算符在C中是否没有余数?

我要检查if/经营者有没有剩余或不:

int x = 0;    
if (x = 16 / 4), if there is no remainder: 
   then  x = x - 1;
if (x = 16 / 5), if remainder is not zero:
   then  x = x + 1;
Run Code Online (Sandbox Code Playgroud)

如何检查是否有剩余C?以及
如何实施它?

c operator-keyword

4
推荐指数
1
解决办法
7436
查看次数

如何从Tcl中的列表中获取值?

我在Tcl中有一个列表:

set list1 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9}
Run Code Online (Sandbox Code Playgroud)

那我怎么能得到基于列表索引的元素?例如:

我想得到这个列表的第二个元素?或者这个清单的第六个?

list tcl

4
推荐指数
2
解决办法
2万
查看次数

以下类型转换在C中做了什么?

我对C中的类型转换有疑问:

void *buffer;

(int *)((int)buffer);
Run Code Online (Sandbox Code Playgroud)

这种类型的铸造做什么?这是((int)buffer)做什么的?

c casting

3
推荐指数
1
解决办法
350
查看次数

我们可以在C中的不同函数中声明相同的局部静态变量吗?

我们可以在C中的不同函数中声明相同的局部静态变量吗?

例如:

in function1:
void function1()
{
   static int a;
   a++;
   //dosomething here
}

in function2:
void function2()
{
   static int a;
   a++;
   //dosomething here
}

in function3:
void function3()
{
   static int a;
   a++;
   //dosomething here
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,如果我调用function1三次,那么我调用函数function3一次,如果函数3中a的值是4还是1?

c static function

3
推荐指数
1
解决办法
4371
查看次数

使用isxdigit()时如何处理C中的数组下标警告?

我在C中有以下代码:

char input[127] = "hello world";

isxdigit(input[0]);
Run Code Online (Sandbox Code Playgroud)

但是我收到了以下警告:

warning: array subscript has type 'char'
Run Code Online (Sandbox Code Playgroud)

是什么原因以及如何解决?

c arrays ctype compiler-warnings

3
推荐指数
1
解决办法
920
查看次数

C中"%02s"和"%2s"之间有什么区别?

我有以下代码:

char temp[32] = "";
sprintf(temp, "%02s", "A");
Run Code Online (Sandbox Code Playgroud)

但它有警告:Warning 566: Inconsistent or redundant format char 's',然后我改为代码:sprintf(temp, "%2s", "A");,警告消失了,有什么区别?

c printf

2
推荐指数
1
解决办法
5027
查看次数

C中二维数组的大小

我有以下二维数组:

#define ROW 100
#define LINE 50

int a[ROW][LINE];
Run Code Online (Sandbox Code Playgroud)

但如何让最后45行的sizeof阵列,例如a[55][0]a[99][99]

我们能做点什么sizeof(&a[55])吗?

c arrays sizeof

2
推荐指数
1
解决办法
2万
查看次数

如何在TCL中组合两个字符串?

我在tcl中有以下代码:

set string1 "do the firstthing"
set string2 "do the secondthing"
Run Code Online (Sandbox Code Playgroud)

如何组合两个字符串 "do the firstthing do the secondthing"

string tcl

2
推荐指数
2
解决办法
1万
查看次数