69,382
社区成员
发帖
与我相关
我的任务
分享
char s[80] = {'\0'};
char t[80] = {'\0'};
#include <iostream.h >
#include <string.h >
#include <stdio.h >
#include <string.h >
void main()
{
char s[80],t[80],i,m;
printf( "Enter a string: ");
gets(s);
printf( "Enter an integer: ");
scanf( "%d",&m);
for(i=0;s[i]!= '\0'&& i <m;i++)
t[i]=s[i];
t[i]='\0';///加上结束标记
printf( "The new string is ");
puts(t);
}