Dynamic Memory allocation Learning notes

Source: Internet
Author: User
#include <stdio.h> #include <stdlib.h>char *substr (const char *s, int n1, int n2) {Char *p = (char *) malloc (n2-n1 +2) int i,j=0;for (i=n1;i<=n2;i++,j++) p[j] = S[i];p [j] = ' + '; return p;} void Main (void) {char s[80], *sub;int N1, n2;printf ("Enter the original string:"), scanf ("%s", s);p rintf ("Enter start and end position:"); scanf ("%d%d",& N1,&N2); sub = substr (s,n1,n2);p rintf ("substring:%s", sub);}


Dynamic Memory allocation Learning notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.