当前位置:首页 » 编程语言 » c语言Dtoh什么意思
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言Dtoh什么意思

发布时间: 2022-05-11 05:38:52

c语言10进制转8进制,程序怎么写

include <stdio.h> #include <math.h> #include <stdlib.h> long dtoe(int a); void dtoh(int a,char h[]); int main(void) { long a; char h[80]; scanf("%d",&a); dtoh(a,h); printf("HEX:%s\n",h); a=dtoe(a); printf("OCT:%d\n",a); system("pause"); return 0; } long dtoe(int a) // 八进制 { if (a<8) { return a; } else return (dtoe(a/8)*10+a%8); } 好好学习 不怕考试 !

❷ 一个C语言的问题

#include <stdio.h>
void dtoh(char sour[],char resu[]){
int x; sscanf(sour,"%d",&x); sprintf(resu,"%x",x);
}
void htod(char sour[],char resu[]){
int x; sscanf(sour,"%x",&x); sprintf(resu,"%d",x);
}
int main(){
char d1[20]="16189", h1[20];
char d2[20], h2[20]="3F3D";
dtoh(d1,h1); printf("%s - %s\n",d1,h1);
htod(h2,d2); printf("%s - %s\n",h2,d2);
return 0;
}

❸ 请问:C语言 程序填充(指针):ditoh 会写吗

#include"stdio.h"
#include"string.h"
chartrans(intx)
{if(x<10)
return'0'+x;
elsereturn'a'+x-10;
}
intDtoH(intn,char*str)
{inti=0;
while(n!=0)
{
str[i]=trans(n%16);
n/=16;
i++;
}
returni-1;}
voidmain()
{inti,k,n;
charstr[30];
scanf("%d",&n);
k=DtoH(n,str);
for(i=0;i<=k;i++)
printf("%c",str[k-i]);}

❹ void dtoh(int)是什么意思

这个是一个函数,传入一个int参数,返回一个空类型!通过函数名不能判断它的具体用处!谢谢,望采纳!

❺ c语言中stdio.h是什么意思

stdio.h是C语言的头文件。

在C语言或C++中,会把用来#include的文件的扩展名叫 .h,称其为头文件。 #include文件的目的就是把多个编译单元(也就是c或者cpp文件)公用的内容。

单独放在一个文件里减少整体代码尺寸;或者提供跨工程公共代码。在现行的c++版本中,应用这个头文件应是#include<stdio.h>。所以,源代码中如用到标准输入输出函数时,就要包含这个头文件。

(5)c语言Dtoh什么意思扩展阅读

C语言stdio.h各函数的用法

fopen:FILE *fopen(const char *filename, const char *mode)

使用给定的模式 mode 打开 filename 所指向的文件。

freopen:FILE *freopen(const char *filename, const char *mode, FILE *stream)

把一个新的文件名 filename 与给定的打开的流 stream 关联,同时关闭流中的旧文件。

fflush:int fflush(FILE *stream)

刷新流 stream 的输出缓冲区。

fclose:int fclose(FILE *stream)

关闭流 stream。刷新所有的缓冲区。

❻ 我想学习C语言,代码基本能看懂,但是涉及到各种进制数转换、“^”、“~”等等这些方面的计算很难理。

代码能看懂就容易上手了,关于你说的数制转换多花点功夫就会解决的,因为都有他的方法,多看看,多练习。还有一个重要的问题就是算法,希望你能好好理解,算法好了就成功了70%。

❼ c语言10进制转8进制以及16进制的源程序

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
long dtoe(int a);
void dtoh(int a,char h[]);

int main(void)
{ long a;
char h[80];
scanf("%d",&a);

dtoh(a,h);
printf("HEX:%s\n",h);
a=dtoe(a);
printf("OCT:%d\n",a);
system("pause");
return 0;
}

long dtoe(int a) // 八进制
{
if (a<8) {
return a;
}
else
return (dtoe(a/8)*10+a%8);
}

void dtoh(int a,char h[]) //十六进制
{
int i;
i=(int)(log(a)/log(16));
h[i+1]=0;
while (a>15) {
if (a%16<10) h[i--]=48+(a%16);
else h[i--]=55+(a%16);
a/=16;
}
if (a>9) h[i]=55+a%16;
else h[i]=48+a%16;

}

***************************************

有什么问题?

是否可以一次把问题描述清楚??

已修正,可以在低版本的TC(如TC++3.0)中运行。

***************************************
在低版本的TC(如TC2\3.0)中不要使用中文,以免对程序的兼容性造成不良影响。

请将问题描述清楚一些好吗??

“还有那个运行到[就出错了.” 是什么意思?

你在什么版本的TC中运行的?
***************************************
你描述的警告我已经去掉了,应该不会出现这些警告了和错误了,

我在TC++3.0中测试时没有出现任何警告和错误,怀疑是你的TC的问题,请尽量使用原版,不要再使用这些非官方的汉化版了

以下是原版TC++3.0 的下载地址:

http://www.wangxvdong.cn/files/TC30.rar

❽ c语言将一个无符号数转换为任意x进制数

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
long dtoe(int a);
void dtoh(int a,char h[]);

int main(void)
{ long a;
char h[80];
scanf("%d",&a);

dtoh(a,h);
printf("HEX:%s\n",h);
a=dtoe(a);
printf("OCT:%d\n",a);
system("pause");
return 0;
}

long dtoe(int a) // 八进制
{
if (a<8) {
return a;
}
else
return (dtoe(a/8)*10+a%8);
}

void dtoh(int a,char h[]) //十六进制
{
int i;
i=(int)(log(a)/log(16));
h[i+1]=0;
while (a>15) {
if (a%16<10) h[i--]=48+(a%16);
else h[i--]=55+(a%16);
a/=16;
}
if (a>9) h[i]=55+a%16;
else h[i]=48+a%16;

}

❾ C语言:编程实现将输入的十进制整数n通过函数DtoH转换为十六进制数,并将转换结果以字符形式输出。

问题不少,首先,10进制不能直接转化为16进制,应该先转为2进制然后再转16进制,其次,char *str 用法错误,只分配了一个字符指针,你却当字符数组使用了,把这两处改了去。