C Language Learning-0002 Excellent code learning

Source: Internet
Author: User

1#include <stdio.h>2#include <stdlib.h>3  4 #defineIni_len 205 #defineINC 106 Char*get_input ();7 voidOutputChar*array);8 intMain () {9printf"Please enter string, double return end: \ n");Ten     Char*string=get_input (); One       AOutputstring); - GetChar (); -     return 0; the } - //Input Function - Char*Get_input () { -     Char*string= (Char*)malloc(ini_len*sizeof(Char)); +     intLen =Ini_len; -     inti =0, cnt =0; +      while(CNT! =2){ A         if(i +1==Len) { atLen + =INC; -             Char* TMP =string; -             string= (Char*)malloc(len*sizeof(Char)); -              for(intK =0; K <= i; ++k) -                 string[K] =Tmp[k]; -              Free(TMP); in         } -         string[I] =GetChar (); to         if(string[I] = ='\ n') +cnt++; -         Else theCNT =0; *i++; $     }Panax Notoginseng     string[I1] =' /'; -     return string; the   + } A //output Function the voidOutputChar*Array) { +     intTag =1, cnt =1; -      for(inti =0; array[i]!=' /'; ++i) { $         if(Tag = =1){ $Tag =0; -             if(Array[i]! ='\ n'&&array[i]! =' /') -printf"%d. ", CNT); the         } -         if(Array[i] = ='\ n'){Wuyi             if(array[i+1] !='\ n'&&array[i+1] !=' /'){ theTag =1; -cnt++; Wu             } -         } Aboutprintf"%c", Array[i]); $     } -}

C Language Learning-0002 Excellent code learning

Related Article

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.