Home > Back-end >  C the input string with a colon how to remove the colon of string
C the input string with a colon how to remove the colon of string

Time:09-27

Everyone a great god
Have something for help, and now to write a program that novice, scanning gun sweep to be 17 string with a colon, how to remove the colon through the code, and then only Numbers,
For example: input the F3: F4: H4: H8: K9: LL through program output is F3F4H4H8K9LL, online, etc., thank you very much!

CodePudding user response:

C language, practice no, write a function to achieve is not ok, not more than 10 lines of code,

CodePudding user response:

The realization of the strcpy function, similar to their character is: it is ok to eat, take a function name is ok,

CodePudding user response:

//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

# pragma hdrstop

#include
#include

//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

# pragma argsused

# define LEN 128

using namespace std;

Int _tmain (int arg c, _TCHAR * argv [])
{
Char from [LEN]="F3, F4: H4: H8: K9: LL";
Char to [LEN];

Int I=0, j=0;
While (I & lt; Strlen (from))
{
If (the from [I]! )=':'
{
The to [j++]=the from [I];
}
i++;
}
The to [j]='\ 0';
Cout & lt; system("PAUSE");
return 0;
}

CodePudding user response:

 
Void __fastcall TForm1: : BitBtn1Click (TObject * Sender)
{
AnsiString s="F3, F4: H4: H8: K9: LL";
S=StringReplace (s, ":", "", TReplaceFlags () & lt; ShowMessage (s);
}

CodePudding user response:

reference 4 floor rouqing response:
 
Void __fastcall TForm1: : BitBtn1Click (TObject * Sender)
{
AnsiString s="F3, F4: H4: H8: K9: LL";
S=StringReplace (s, ":", "", TReplaceFlags () & lt; ShowMessage (s);
}
this good, CB standard way!
  • Related