Creo two times develop asynchronous mode--string manipulation function

Source: Internet
Author: User

Through these 2 functions, the main completion of the construction of the file name

( 1 ) _splitpath function--Decomposition path function

char*drwfullpath = "D:\\TEST\\8102.DRW";

CHARSAVEDRIVE[200];

CHARSAVEDIR[200];

CHARSAVENAME[100];

CHARSAVEEXT[50];

_splitpath (Drwfullpath,savedrive,savedir,savename,saveext);

Results: Savedrive=d:

Savedir=\test\

savename=8102

Saveext=.drw

(2)strcatFunction--putsrcThe referred string is added to thedestat the end(coverdestat the end of the' + ')and add' + '.

extern char *strcat (char *dest,char *src); The header file should contain #include <string.h>

//pdf put it in the same directory. Results directory under

strcat (Savedir, "result\\");

Char *savepath = strcat (Savedrive,savedir);

mkdir (Savepath);

Char*destpdffullnamenoext = strcat (savedrive,savename);

CHARDESTDXFFULLNAME[1024];

sprintf (Destdxffullname, "%s.dxf", Destpdffullnamenoext);

Char *destpdffullname =strcat (Destpdffullnamenoext, ". pdf");

               // The resulting result is: "D:\\test\\8102.pdf";

Additional functions:

strstr function--searches for the first occurrence of a string in another string. When the searched string is found, the function returns the address of the first matching string, or NULL if the searched string is not found .

&NBSP;

extern   char   * strstr ( char &NBSP; *str1,  const &NBSP; Char &NBSP; *str2);

str1: target being searched for stringexpression to search.

str2: to find an object thestring expression to find.

return value: If str2 str1 str2 in str1 str1 str2 str2 str1

Example:

1

2

3

Char str[]= "1234xyz";

Char *str1=strstr(str, "the");

cout << str1 << Endl;

shown is the : 34xyz


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Creo two times develop asynchronous mode--string manipulation function

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.