题解 | #截取字符串#
截取字符串
https://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
#include <stdio.h> #include <string.h> int main(){ int k; char arr[1000] = {0}; fgets(arr, sizeof(arr), stdin); scanf("%d", &k); /* for(int i = 0; i < k; i++){ printf("%c",*(arr + i)); } */ printf("%.*s",k,arr); return 0; }