Dotcpp  >  编程教程  >  stdlib.h头文件  >  C语言swab()函数:从源和目标区域交换字节

C语言swab()函数:从源和目标区域交换字节

点击打开在线编译器,边学边练

函数名:swab

头文件:<stdlib.h>

函数原型: void swab(char *from,char *to,int n);

功能:从源和目标区域交换字节

参数: char *from 和 char *to  为要交换字节的字符串

           int n  为需要交换的字节数

返回值:没有返回值


程序例: 使用该函数将字符串"ww.wodctppc.mo"交换成"www.dotcpp.com".

#include<stdio.h>

#include<stdlib.h>
#include<string.h>

#include<time.h>

int main(void){

    char suc[20]={"ww.wodctppc.mo"};

    char des[20];

    swab(suc,des,strlen(suc));

    printf("This is dest: %s\n",des);

    return 0;

}

 

运行结果

This is dest: www.dotcpp.com



本文固定URL:https://www.dotcpp.com/course/568

C语言函数库
assert.h头文件
ctype.h头文件
float.h头文件
io.h头文件
math.h头文件
mem.h头文件
setjmp.h头文件
stdio.h头文件
stdlib.h头文件
sigal.h头文件
string.h头文件
time.h头文件
Dotcpp在线编译      (登录可减少运行等待时间)