Place a string in separate strings by odd and even digits

Source: Internet
Author: User

Title Description: Given a string
Requires writing a function that implements the following functions
Function 1: Bar even digit characters are picked out to form a string
Feature 2: bar odd digit characters are picked out to form a string



Stores a string in different strings by odd and even digits # define _crt_secure_no_warnings#include <stdlib.h> #include <string.h># Include<stdio.h>int getstr1str2 (char * source, Char *buf1, char *buf2) {char *p = Source;int num = 0; Record function return value if (Source = = NULL | | buf1 = = NULL | | buf2 = = NULL)//Determine if NULL pointer {num = -1;printf ("func getstr1str2 () Err (source = = NULL | | BUF1 = = NULL | | Buf2 = = NULL):%d ", num); return num;} int i = 9;int j = 0;int m = 0;for (m=0,i = 0, j = 1; I < strlen (source) && J < strlen (source); m++) {Buf1[m] = Source[i];buf2[m] = Source[j];i = i + 2;j = j + 2;} Buf1[m] = ' n '; buf2[m] = ' + ';} void Main () {char *str_old = "1a2b3d4c"; char Str_new1[100];char str_new2[100];getstr1str2 (Str_old, Str_new1, STR_NEW2); printf ("str_old:%s \ n", Str_old);p rintf ("str_new1:%s \ n", Str_new1);p rintf ("str_new2:%s \ n", str_new2); System ("Pause "); return;}

  

Place a string in separate strings by odd and even digits

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.