跪求C语言程序:编写含有特定字符串的构建器

来源:百度知道 编辑:UC知道 时间:2024/05/28 03:17:55

输入字符串长度
依次输入字符串中每个字符的ASCII值,构建字符串

#include <stdio.h>
#include <stdlib.h>

void main()
{
int x[100];
char s[100];
int i,n;
printf("input ASCII values, the prog will generates string\n");
printf("input the total number of the string\n");
scanf("%d",&n);

for (i=0;i<n;i++)
{
printf("\nplease input ASCII value for char %d: ",i+1);
scanf("%d",&x[i]);
s[i] = x[i] & 0x00ff;
}
s[n] = '\0';
printf("\nThe string is %s",s);
}

例如:
5
66
67
68
69
70
得 The string is BCDEF

例如:
2
143
102
得 The string is Åf