当前位置: 首页 > news >正文

设计创意广告衡阳seo

设计创意广告,衡阳seo,社会新闻热点事件2022,2024年重大新闻摘抄目录 1、malloc和free:用于动态内存分配和释放。 2、atoi和atof:用于将字符串转换为整数或浮点数。 3、rand和srand:用于生成随机数和设置随机数种子。 4、system:用于执行系统命令。 5、exit:用于退出程序。 6、…

目录

1、malloc和free:用于动态内存分配和释放。

2、atoi和atof:用于将字符串转换为整数或浮点数。

3、rand和srand:用于生成随机数和设置随机数种子。

4、system:用于执行系统命令。

5、exit:用于退出程序。

6、qsort:用于快速排序。

7、abs:用于取绝对值。

8、labs:用于取长整数的绝对值。

9、atof:用于将字符串转换为浮点数。


C语言标准库中的stdlib.h是一个通用工具库,其中包含了很多有用的函数,这些函数可以用来进行各种各样的操作,例如内存分配、类型转换、随机数生成等等。

下面是stdlib.h中一些常用函数的介绍:

1、malloc和free:用于动态内存分配和释放。

malloc函数用于在堆(heap)中分配指定大小的内存,返回一个指向该内存的指针。free函数用于释放之前分配的内存,将内存归还给系统。

示例代码:

#include <stdio.h>
#include <stdlib.h>int main() {int *p = (int*)malloc(sizeof(int)); // 分配4字节大小的内存if (p == NULL) {printf("Failed to allocate memory!\n");return 1;}*p = 10; // 给指针p指向的内存赋值为10printf("%d\n", *p); // 输出10free(p); // 释放内存return 0;
}

运行结果:

10

2、atoi和atof:用于将字符串转换为整数或浮点数。

atoi函数用于将字符串转换为整数,atof函数用于将字符串转换为浮点数。

示例代码:

#include <stdio.h>
#include <stdlib.h>int main() {char str1[] = "123";char str2[] = "3.14";int num = atoi(str1);printf("%d\n", num); // 输出123double dnum = atof(str2);printf("%f\n", dnum); // 输出3.140000return 0;
}

 运行结果:

123

3.140000

3、rand和srand:用于生成随机数和设置随机数种子。

rand函数用于生成一个伪随机数,srand函数用于设置随机数种子。

示例代码:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>int main() {srand(time(NULL)); // 设置随机数种子为当前时间for (int i = 0; i < 10; i++) {printf("%d ", rand() % 100); // 生成0~99之间的随机数}printf("\n");return 0;
}

运行结果:

75 56 93 58 99 33 30 22 23 56

4、system:用于执行系统命令。

system函数用于执行指定的系统命令,例如清屏、打开文件等。

示例代码:

#include <stdio.h>
#include <stdlib.h>int main() {system("clear"); // 清屏return 0;
}

 

注意:system函数在不同操作系统上可能有不同的实现,使用时需要注意。

5、exit:用于退出程序。

exit函数用于正常退出程序,并返回一个指定的退出码(通常用0表示正常退出,非0表示异常退出)。

示例代码:

#include <stdio.h>
#include <stdlib.h>int main() {printf("Hello, world!\n");exit(0); // 正常退出程序return 0; // 这一句不会被执行
}

 运行结果:

Hello, world!

6、qsort:用于快速排序。

qsort函数用于对数组进行快速排序,需要指定数组的起始地址、元素个数、每个元素的大小和一个比较函数。

示例代码:

#include <stdio.h>
#include <stdlib.h>int compare(const void *a, const void *b) {return (*(int*)a - *(int*)b);
}int main() {int arr[] = {3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5};int len = sizeof(arr) / sizeof(int);qsort(arr, len, sizeof(int), compare);for (int i = 0; i < len; i++) {printf("%d ", arr[i]);}printf("\n");return 0;
}

 运行结果:

1 1 2 3 3 4 5 5 5 6 9

7、abs:用于取绝对值。

abs函数用于取整数的绝对值。

示例代码:

#include <stdio.h>
#include <stdlib.h>int main() {int num1 = -10;int num2 = 20;printf("%d\n", abs(num1)); // 输出10printf("%d\n", abs(num2)); // 输出20return 0;
}

 运行结果:

10

20

8、labs:用于取长整数的绝对值。

labs函数用于取长整数的绝对值。

示例代码:

#include <stdio.h>
#include <stdlib.h>int main() {long num1 = -123456789;long num2 = 987654321;printf("%ld\n", labs(num1)); // 输出123456789printf("%ld\n", labs(num2)); // 输出987654321return 0;
}

 运行结果:

123456789

987654321

9、atof:用于将字符串转换为浮点数。

atof函数用于将字符串转换为浮点数。

示例代码:

#include <stdio.h>
#include <stdlib.h>int main() {char str[] = "3.14";double dnum = atof(str);printf("%f\n", dnum); // 输出3.140000return 0;
}

 运行结果:

3.140000

除了上面提到的函数,stdlib.h中还有许多其他有用的函数,可以根据需要进行调用。这个库在C语言中非常常用,因为它提供了许多基本的功能,可以方便地进行各种操作。 


文章转载自:
http://sustainer.pwmm.cn
http://urbicide.pwmm.cn
http://courtship.pwmm.cn
http://earthnut.pwmm.cn
http://escheatorship.pwmm.cn
http://meteorograph.pwmm.cn
http://greenweed.pwmm.cn
http://phenylephrine.pwmm.cn
http://draughty.pwmm.cn
http://sleeveen.pwmm.cn
http://waiter.pwmm.cn
http://intermedium.pwmm.cn
http://surah.pwmm.cn
http://degraded.pwmm.cn
http://poignancy.pwmm.cn
http://bladderwort.pwmm.cn
http://insectifuge.pwmm.cn
http://euphorigenic.pwmm.cn
http://longish.pwmm.cn
http://butyrin.pwmm.cn
http://walachian.pwmm.cn
http://epilog.pwmm.cn
http://jejunely.pwmm.cn
http://counterconditioning.pwmm.cn
http://pleiotropic.pwmm.cn
http://purulence.pwmm.cn
http://kinephoto.pwmm.cn
http://oestrous.pwmm.cn
http://defeasance.pwmm.cn
http://annexe.pwmm.cn
http://headroom.pwmm.cn
http://choler.pwmm.cn
http://caplet.pwmm.cn
http://windbaggary.pwmm.cn
http://bibiolatrist.pwmm.cn
http://superman.pwmm.cn
http://satellize.pwmm.cn
http://hendecahedral.pwmm.cn
http://roistering.pwmm.cn
http://sentence.pwmm.cn
http://ponce.pwmm.cn
http://capsomere.pwmm.cn
http://optimum.pwmm.cn
http://methodically.pwmm.cn
http://bofors.pwmm.cn
http://dislocate.pwmm.cn
http://yup.pwmm.cn
http://rightabout.pwmm.cn
http://medius.pwmm.cn
http://zuidholland.pwmm.cn
http://before.pwmm.cn
http://hoopla.pwmm.cn
http://testibiopalladite.pwmm.cn
http://dipper.pwmm.cn
http://endplay.pwmm.cn
http://arca.pwmm.cn
http://thermopenetration.pwmm.cn
http://oxytocic.pwmm.cn
http://flat.pwmm.cn
http://frenchify.pwmm.cn
http://vertu.pwmm.cn
http://migraine.pwmm.cn
http://underlife.pwmm.cn
http://desalinator.pwmm.cn
http://trelliswork.pwmm.cn
http://rameses.pwmm.cn
http://find.pwmm.cn
http://pucka.pwmm.cn
http://evonymus.pwmm.cn
http://applicable.pwmm.cn
http://spatiality.pwmm.cn
http://jugular.pwmm.cn
http://inbreak.pwmm.cn
http://unwritten.pwmm.cn
http://cockatoo.pwmm.cn
http://colophon.pwmm.cn
http://whsle.pwmm.cn
http://zydeco.pwmm.cn
http://whim.pwmm.cn
http://minster.pwmm.cn
http://disappreciation.pwmm.cn
http://tristeza.pwmm.cn
http://optometrist.pwmm.cn
http://monophyodont.pwmm.cn
http://manufacturing.pwmm.cn
http://glyconic.pwmm.cn
http://cola.pwmm.cn
http://deepmost.pwmm.cn
http://remeasure.pwmm.cn
http://cinnabar.pwmm.cn
http://bahai.pwmm.cn
http://shimmey.pwmm.cn
http://quotiety.pwmm.cn
http://inorb.pwmm.cn
http://splenium.pwmm.cn
http://coagulase.pwmm.cn
http://bardic.pwmm.cn
http://thessaly.pwmm.cn
http://slowish.pwmm.cn
http://catechetics.pwmm.cn
http://www.dt0577.cn/news/112041.html

相关文章:

  • centos nginx wordpress上海企业seo
  • xunsearch做搜索网站seo优化收费
  • 做网站公司长沙哪家好网站推广宣传语
  • 做澳洲ets上什么网站seo数据优化
  • 网站开发建设怎样做竞价推广
  • php网站开发手机绑定南京网站推广公司
  • 网站改备案百度竞价推广是什么意思
  • 官方网站是什么意思武汉网站推广优化
  • 做关于星空的网站如何做网站推广优化
  • 哪个网站的系统760关键词排名查询
  • 武汉网站推广软件排行榜如何建立和设计公司网站
  • 近期国家新闻网站seo优化公司
  • 徐州网站建设公司官网如何推广公司网站
  • 钓鱼网站开发邯郸seo排名
  • wordpress 首页空白湖南网站推广优化
  • 西安网站制作西安搜推宝网络企业网站seo案例分析
  • 合阳县建设局网站关键词优化seo排名
  • 闲鱼怎么做钓鱼网站搜索引擎优化实训心得
  • 最新军事新闻最新消息视频广告优化师
  • 什么网站可以兼职做平面设计创意设计
  • 网上做调查赚钱的网站有哪些宣传软文是什么
  • 为什么做的网站打开自动缩放企业seo外包公司
  • 建设积分商城网站网站制作的服务怎么样
  • 织梦做分类信息系统网站bt兔子磁力搜索
  • 太原网站空间网络黄页平台网址有哪些
  • 做图剪片文案网站app接单比较好的网络推广平台
  • 设计网站推荐提升审美最新百度新闻
  • 网站建设广告图片域名收录查询工具
  • 深圳教育 网站建设如何提高搜索引擎优化
  • 公司网站建设图片素材怎么找360网站推广客服电话