相关疑难解决方法(0)

整数到IP地址 - C.

我正在准备一个测验,我怀疑我可能会负责实现这样的功能.基本上,给定一个网络符号的IP地址,我们如何从一个32位整数到它的点分十进制表示法(如155.247.182.83)...?显然我们也不能使用任何类型的inet函数......我很难过!

c string ip-address

23
推荐指数
4
解决办法
10万
查看次数

ANSI C(ISO C90):scanf可以读取/接受unsigned char吗?

简单的问题:scanf可以读取/接受"小整数"到ANSI C中的unsigned char吗?

示例代码un_char.c:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    unsigned char character;

    scanf("%hhu", &character);

    return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)

编译为:

$ gcc -Wall -ansi -pedantic -o un_char un_char.c
un_char.c: In function ‘main’:
un_char.c:8: warning: ISO C90 does not support the ‘hh’ gnu_scanf length modifier
Run Code Online (Sandbox Code Playgroud)

hhISO C90不支持.那么在这种情况下可以使用什么scanf转换?

c gcc scanf c89

15
推荐指数
2
解决办法
5713
查看次数

scanf()可以存储值吗?

嗨,我现在正在学习C语言,并且练习我读过的书时遇到了一些问题.我的代码是这样的:

#include<stdio.h>
int main()
{
  unsigned char one=0;
  unsigned char two=0;
  printf("Quantity 1 = ");
  scanf("%d",&one);
  printf("Quantity 2 = ");
  scanf("%d",&two);
  printf("The value is %d",one);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

为什么当我试图看到one初始值的值出现而不是后面的值scanf?

c scanf

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

标签 统计

c ×3

scanf ×2

c89 ×1

gcc ×1

ip-address ×1

string ×1