Get string Middle by C

Source: Internet
Author: User


int int int'n '; i++ ) {;}}     

For example:

1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4 5 #defineStr_len 106 7 voidStr_get_middlle (Char*result,Char*STR,intStartintend);8 9 intMainintargcChar*argv[])Ten { OneFILE *FP =NULL; A     Char*file_path =NULL; -     CharStr[str_len] ="", result[str_len] =""; -  the     if(ARGC = =1){ -printf"Too few augument (s) \ n" ); - exit (exit_failure); -     } +  -File_path = * (+ +argv); +  A     if(fp = fopen (File_path,"R")) ==NULL) { atprintf"Opening file error! path:%s\n", File_path); - exit (exit_failure); -     } -     Else{ -printf"Opening file [%s] was successfully!\n", File_path); -     } in  -  to      while(Fgets (str,sizeof(str), FP)! =NULL) { + //printf ("%s", str);  -Str_get_middlle (result, str,0,1); theprintf"%s-", result); *  $Str_get_middlle (result, str,2,3);Panax Notoginsengprintf"%s-", result); -  theStr_get_middlle (result, str,4,5); +printf"%s\n", result); A     }  the      +     return 0; -}

Means: 00112233 >> 00-11-22-33. This code can formt MAC address.

Get string Middle by C

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: 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.