题解 |循环?开什么玩笑~10行拿捏
截取字符串
http://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
要切字符串前n个,那直接把下标n变成结束标志就行了
#include <stdio.h>
int main()
{
char str[101];
while(scanf("%s", str) > 0) {
int n;
scanf("%d", &n);
str[n] = '\0';
printf("%s\n", str);}
}