如标题一样;问“First and last name: “ 输出 First name首字母和全部last name
不过全部字母都要小写,且超过8个字母部分不显示
比如:输入 Steven Lee
输出 slee
输入 Buford␣McGillicuddy
输出 bmcgilli
输入 ␣␣␣␣␣␣␣␣␣␣Immanuel␣␣␣␣␣␣Kant␣␣␣
输出 ikant
本人是c语言菜鸟,基础极差约等于没有,感兴趣选择了计算机科学,但是作业第一题就难倒我了
今天试了一整个下午都没想到该怎么解,本来想从一开始基础自学然后自己做这题,但是时间不够了
求大佬们帮忙
下面是我的代码(我也不清楚我在写什么)
#include
#include
#include
#include
int main(void)
{
string s = get_string("First and last name: ");
int i = 0;
while(isspace(s[i]))
{
i++;
}
if(s[i] != '\0')
{
printf("%c", s[i]);
}
}
知道不好学,就别拿这个当打游戏,你喜欢你要想想你为什么喜欢,我姑且认为你学的是c:
#include <stdio.h>
#include <string.h>
int main(void)
{
char name[64];
char* index;
printf("First and last name: ");
gets(name);
index = strchr(name, ' ');
printf("%s", index+1);
return 0;
}