[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>C语言中字符串的使用
java语言中直接就有string这个数据类型,而C语言中没有字符串数据类型,所以使用字符串的时候,难免会不是很方便,那么现在就总结一下C语言中字符串的使用!
<>1.字符串的声明
(1)使用字符数组来存储字符串
#include <stdio.h> int main() { char a[10]; printf("请输入字符串:\n"); scanf("%s",a);
printf("字符串的值为:\n"); printf("%s",a); return 0; }
(2)使用指针,其实本质是一样的,都是从首地址开始,将标准输入中的内容存到以这个地址开头的一片连续空间中!
#include <stdio.h> #include <stdlib.h> int main() { char* str; str=(char*)
malloc(sizeof(char)*10); printf("请输入字符:\n"); gets(str); printf("输出字符串:\n"); puts
(str); return 0; }
<>2.字符串的输入输出
<>(1)使用scanf和printf
这俩函数用途比较广泛,可以用来输入输出int char float等。同样可以输入输出字符串,只不过这里的占位符是%s,
<>(2)使用gets和puts
这俩函数只能用于字符串的输入输出
<>(3)这两套的区别:
scanf遇到空格、回车就会终止!而gets认为空格也是字符,可以将空格输入,遇到回车才会终止!
printf输出时,需要加\n才会换行;而puts函数自带换行功能!!!
Talk is cheap.Show you the code!
#include <stdio.h> int main() { char a[10]; printf("请输入字符串:\n"); scanf("%s",a);
printf("字符串的值为:\n"); printf("%s",a); printf("你看我换行吗"); return 0; }
效果:
#include <stdio.h> #include <stdlib.h> int main() { char* str; str=(char*)
malloc(sizeof(char)*10); printf("请输入字符:\n"); gets(str); printf("输出字符串:\n"); puts
(str); printf("你看我换行吗!"); return 0; }