小编Ibt*_*med的帖子

为什么在 C 中未初始化的数组元素不总是 0

我输入 4566371 并发现未初始化的数组元素不是我们文本中所说的 0


#include <stdio.h>
#define MAX 10

// Function to print the digit of
// number N
void printDigit(long long int N)
{
 // To store the digit
 // of the number N
 int array_unsorted[MAX];//array_unsorteday for storing the digits
 int i = 0;//initializing the loop for the first element of array_unsorted[]
 int j, r;

 // Till N becomes 0,we will MOD the Number N
 while (N != 0) {

     // Extract the right-most digit of N
     r = …
Run Code Online (Sandbox Code Playgroud)

c arrays

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

\r 和 \n 的深度区别

这是我计算给定字符串的字符数的代码(即使用strlen()函数):

#include <stdio.h>
#include <string.h>

#define N 30

int main() {
    char input[N];
    gets(input);
    int j = strlen(input);
    printf("using library fnc strlen=%d", j);
    int i = 0, sum = 0;
    for (i = 0; input[i] != '\0'; i++) {
        sum = sum + i;
    }
    printf("\rusing loop %d", sum);
}
Run Code Online (Sandbox Code Playgroud)

在Code::Blocks(gcc编译器)上,结果显示如下:

abcdef78
using loop 4y fnc strlen=8
Process returned 0 (0x0)   execution time : 5.816 s
Press any key to continue.
Run Code Online (Sandbox Code Playgroud)

但是Programiz的在线编译器显示是这样的:

/tmp/rzNX0Zm3SF.o
abcdef78
using library …
Run Code Online (Sandbox Code Playgroud)

c

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

C 中的浮点数由哪几部分组成?

单精度浮点:
符号位:1
指数:8位
尾数:23位

双精度浮点:
符号位:1
指数:11位
尾数:52位

这个信息是什么意思?我不太了解英语术语。

c floating-point

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

标签 统计

c ×3

arrays ×1

floating-point ×1