#include "stdlib.h"
#include "stdio.h"
#include "string.h"
int main(int argc, char* argv[])
{
int *test = malloc(15 * sizeof(int));
for(int i = 0;i < 15 ;i ++ )
printf("test is %i\n",test[i]);
memset(test,0,sizeof(int) * 15);
for(int i = 0 ; i < 15; i ++ )
printf("test after memset is %i\n",test[i]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到的输出非常奇怪:
test is 1142126264
test is 32526
...
test is 1701409394
test is 1869348978
test is 1694498930
test after memset is 0
test after memset is 0
test …Run Code Online (Sandbox Code Playgroud) 如果我这样写:
typedef enum {
foo_1,
foo_2
}foo ;
Run Code Online (Sandbox Code Playgroud)
我发现我可以使用
int footype = foo::foo_1 在c ++中
我可以直接使用
int footype = foo_1 在c中,
那么是否有一种方法可以编写在c ++和c中都能运行的相同代码?代码在一个只有一个结构的头文件中.
说这样的结构:
typedef struct testVertex_s {
char *vert_name; //for test only...
float x;
float y;
float z;
}testvertex_t;
Run Code Online (Sandbox Code Playgroud)
如何使用python将其写入二进制文件?我想用c中的fread读它;
我试图循环一个char*str使用它来找出多少行:
char *str = "test1\ntest2\ntest3";
int lines = 0;
for(int i = 0 ; i < ?? ; i ++ )
{
if(str[i] == '\n') {
lines++;
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道该放什么?,问题是:
1.我的意思是我需要使用strlen(str)+ 1吗?
2.当str为"test1 \ntest2 \ntest3 \n"时,代码是否仍然计算正确的行?
我顺便使用gcc,谢谢
可能吗?如果我有2个四边形的8个顶点和单独的位置(基于四边形),是否可以通过一次调用glDrawElement来绘制这个四边形中的两个?