练习9-1
#include <stdio.h>
int main()
{
char str[] = "ABC\0DEF";
printf("字符串str为\"%s\"。\n", str); /* 显示 */
return 0;
}
练习9-2
/*---让该初始化赋值得到的字符串s变成空字符串:char s[] = "ABC"---*/
#include <stdio.h>
int main ()
{
char s[] = "ABC";
s[0] = '\0';//*str = 0;
printf("字符串s为:%s",s);
return 0;
}
练习9-3
#include<stdio.h>
#define NUM 3
int main(void)
{
int i;
char s[NUM][128];
for (i = 0; i < NUM; i++)
{
printf("s[%d]:", i);
scanf("%s", s[i]);
if (strcmp(s[i], "$$$$$") == 0)
break;
}
for (i = 0; i < NUM; i++)
{
if (strcmp(s[i], "$$$$$") == 0)
break;
else
printf("s[%d] = \"%s\"\n", i, s[i]);
}
return 0;
}
练习9-4
#include<stdio.h>
void n

本文介绍了C语言中一系列关于字符串操作的练习,包括初始化字符串、打印、查找特定字符、反转字符串和删除数字等,展示了基础的字符串处理技巧。
 第九章练习答案&spm=1001.2101.3001.5002&articleId=134675507&d=1&t=3&u=74b0c10e42044d27bbf028dea3908c2d)
1404

被折叠的 条评论
为什么被折叠?



