小编cok*_*ude的帖子

按位和C编程

我可以请一些帮助理解一下,如果是速记吗?我评论了我的想法.

//Bitwise AND not sure how it decides 32 or 0, then set board[i]    
board[i] = (randNum & 1024) ? 32 : 0;

//it the j variable j in the neighborOffset array, then mods it by 2048
//then takes that variable from the board array, then shifts 1 to 32
//then bitwise and of those 2 variables.
if(board[(i + neighborOffset[j]) % 2048] & (1 << 5))

//Not sure about this one. Can someone please explain it? 
board[i] |= ((board[i] ^ …
Run Code Online (Sandbox Code Playgroud)

c

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

读取不一致的文件

C中哪些文件读取器可以处理读取不一致的文件?有时文件是"字号",有时它只是"字".像这样.

bob 456
echo
cat 
dog 1101
peacock 300
Run Code Online (Sandbox Code Playgroud)

这就是我用fscanf尝试过的.我很惊讶它的工作原理.我不认为fscanf喜欢不一致的文件.有什么我需要担心的吗?我知道如果你不小心,fscanf会有非常糟糕的副作用.

while (fscanf(pFile, "%s %d",  nam, &val) !=EOF)
{
    //my work
}
Run Code Online (Sandbox Code Playgroud)

c file-io scanf

0
推荐指数
1
解决办法
103
查看次数

在此函数中使用未初始化

我正忙着这个功能.

void GetBaseDeclarationLabel(char *strings_label_table1[], char *strings_mneumonic_table1[],
         char *strings_operand_table1[], int hex_address_table1[], char *base_label)
{
    int i = 0;
    int cmp_str2 = 0;
    //char label[20] = {0}; 
    //int k = 0; 
    //printf(" i is %s \n", strings_label_table1[1]); 
    for(i = 0; i < 503; i++)
    {
        if(strings_mneumonic_table1[i] != NULL)
        {
            cmp_str2 = strcmp(strings_mneumonic_table1[i], "BASE");
            if(cmp_str2 == 0)
            {
                //printf(" ??please?? \n");
                //printf(" hex_address_table1[i] is %x \n", hex_address_table1[i]);
                //strcpy(label, strings_operand_table1[i]);
                base_label = malloc(strlen(strings_operand_table1[i])+1);
                strcpy(base_label, strings_operand_table1[i]);
                //base_label = strings_operand_table1[i]; 
                break;
            }
        }

    }
    //return label; …
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
5856
查看次数

标签 统计

c ×3

file-io ×1

scanf ×1