Home > Back-end >  C write a custom class constructor, then can output the substring
C write a custom class constructor, then can output the substring

Time:11-28

No direct reference string
To define a
Their input passage, for example: hello world
Hel (0, 3) output

CodePudding user response:

I come to pick up points

 
Int main ()
{
Char buf [1024].
Gets_s (buf, 1024);

Int the begin;
int len;
Scanf_s (" % d, % d ", & amp; The begin, & amp; Len);

Int charLen=strlen (buf);
For (int I=begin; I & lt; The begin + len & amp; & I & lt; CharLen; + + I)
{
Printf (" % c ", buf [I]);
}

printf("\r\n");

system("pause");

return 0;
}


Hello World!
2, 5
Llo W
Please press any key to continue...
  • Related