我有以下代码:
#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)
问题是什么以及如何解决?
我有以下代码:
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)
我们怎么会知道第二1的array是最后1我们发现了什么?我不是说保持最后的价值1,我的意思是我们应该怎么知道第二次1是最后一次出现,再没有出现?
我要检查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?以及
如何实施它?
我在Tcl中有一个列表:
set list1 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9}
Run Code Online (Sandbox Code Playgroud)
那我怎么能得到基于列表索引的元素?例如:
我想得到这个列表的第二个元素?或者这个清单的第六个?
我对C中的类型转换有疑问:
void *buffer;
(int *)((int)buffer);
Run Code Online (Sandbox Code Playgroud)
这种类型的铸造做什么?这是((int)buffer)做什么的?
我们可以在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中有以下代码:
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)
是什么原因以及如何解决?
我有以下代码:
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");,警告消失了,有什么区别?
我有以下二维数组:
#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])吗?
我在tcl中有以下代码:
set string1 "do the firstthing"
set string2 "do the secondthing"
Run Code Online (Sandbox Code Playgroud)
如何组合两个字符串 "do the firstthing do the secondthing"