在C中,我有两个char数组:
char array1[18] = "abcdefg";
char array2[18];
Run Code Online (Sandbox Code Playgroud)
如何复制的价值array1
来array2
?我可以这样做array2 = array1
吗?
在以下代码中:
int c;
while((c=10)>0)
Run Code Online (Sandbox Code Playgroud)
什么是c = 10
评价什么?是1表示值10成功分配给变量c,还是10?为什么?
如何在C中记忆二维数组:
我有一个二维数组:
int a[100][100];
int c[10][10];
Run Code Online (Sandbox Code Playgroud)
我想使用memcpy
将数组c中的所有值复制到数组a,如何使用memcpy执行此操作?
int i;
for(i = 0; i<10; i++)
{
memcpy(&a[i][10], c, sizeof(c));
}
Run Code Online (Sandbox Code Playgroud)
它是否正确?
在C的主要功能:
void main(int argc, char **argv)
{
// do something here
}
Run Code Online (Sandbox Code Playgroud)
In the command line, we will type any number for example 1
or 2
as input, but it will be treated as char array for the parameter of argv, but how to make sure the input is a number, in case people typed hello
or c
?
如何将int
数组中的MAC地址转换为C中的字符串?例如,我使用以下数组来存储MAC地址:
int array[6] = {0x00, 0x0d, 0x3f, 0xcd, 0x02, 0x5f};
Run Code Online (Sandbox Code Playgroud)
如何将其转换为字符串,如"00:0d:3f:cd:02:5f"
?
我想在C++中调用以下代码,我无法更改:
void getAge(char *name)
{
// do something
}
Run Code Online (Sandbox Code Playgroud)
当我打电话给它时getAge("hello");
,它有以下警告:
warning: deprecated conversion from string constant to 'char*'
Run Code Online (Sandbox Code Playgroud)
但C代码中没有警告.有什么区别,如何更改调用以避免C++中的警告?
我看到了一些像这样的c代码:int check = 10:
switch(check) {
case 1...9: printf("It is 2 to 9");break;
case 10: printf("It is 10");break;
}
Run Code Online (Sandbox Code Playgroud)
这case 1...9:
是什么意思?它是标准的吗?
我在git中有一些藏匿文件,但我不想git stash pop
这样,因为有时候它会提醒合并消息,我不想做合并以便在stashed文件中看到源代码,有没有办法做到这一点?
我有以下代码:
int isUsed[6] = {1,1,1,1,1,1};
Run Code Online (Sandbox Code Playgroud)
如何比较此数组中的所有元素是否等于1?还是其他价值?我知道我们可以循环数组并逐一比较它,但我们还有其他方法吗?
我有以下代码:
#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)
问题是什么以及如何解决?