你好,我是在编程很新,想了解一些从你:) 我做以.c程序,我在stucked部分。 我想获得3个或更多的输入最多5个字符的大小。 (例如:HELLO,HI,GOOD,BYE) ,我想将它们堆叠在其保持相同的字母从这些4个字符串仅一次一个新的字符串 (实施例:H,E,L,L,O,I,G ,D,B,Y)组合两个字符串连接为一个字符串,它消除了在C相同的字母
#include <stdio.h>
#include <string.h>
int main(void) {
char first[5], second[5], third[5], fourth[5];
printf("Enter 1st word: \n"); scanf(" %5s", &first);
printf("Enter 2nd word: \n"); scanf(" %5s", &second);
printf("Enter 3rd word: \n"); scanf(" %5s", &third);
printf("Enter 4th word: \n"); scanf(" %5s", &fourth);
char stack[21]; // i want a new string like this and then combine first 4 strings
// in this string...
return 0;
}
我希望你能让我知道我可以做到这一点。 (我也是在该网站新我搜索了这一点,但我找不到很抱歉,如果它的存在。)
你想在结果字符串中的字母是以任何特定的顺序? – 5gon12eder 2014-12-06 18:08:25
@ 5gon12eder - 不,我只是想把这些字符串结合在一个字符串中去掉多余的字母。 – Gorki 2014-12-06 18:18:16
我建议使堆栈数组[21]考虑到所有唯一字母(和null)的可能性。 – doppelheathen 2014-12-06 18:23:56