473,748 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Whats is the equivalent way to strcpy in C#

1 New Member
I want to write a C++ function in C#:

the C++ code:

#define deleter "/.:_-";
char code[25]; // SR2342-23422-234234

Expand|Select|Wrap|Line Numbers
  1. int take_mod(char *number,int anz,int position)
  2. {
  3.     int k=0,n=0;
  4.  
  5.     while (zahl[n]!=0)
  6.     {              
  7.          k=(int)number[n];
  8. #ifdef blank
  9.         if ((strchr(deleter,k) !=0) || (!isdigit(number[n])))
  10.         {
  11. #ifdef delete_blank
  12.             strcpy(number+n,number+n+1);
  13. #else
  14.             n++;
  15. #endif
  16.             continue;
  17.         }
  18. }
C# code:

Expand|Select|Wrap|Line Numbers
  1.  public int take_mod(string number, int anz, int position) {
  2.             int i = 0, k = 0,  n = 0 , u = 0;
  3.             char numberValue;
  4.  
  5.             while (number[n] != 0) {
  6.                 k = number[n];
  7.                 numberValue= number[n];
  8. #if deleter
  9.                 if ((number.IndexOf(deleter[u]) != 0) || (!Char.IsDigit(numberValue))) {
  10. #if delet_blanks
  11.                     number = number[n + 1].ToString();
  12. #else  
  13.                 n++;
  14.                 u++; // u ++ ?????????????
  15. #endif
  16.                 continue;
  17.                 }
  18. #endif
  19. }
I want to run the 24 x characters (SR2342-23422-234234) and delete the alphanumerics and blanks.

thx?
Sep 17 '13 #1
0 2373

Sign in to post your reply or Sign up for a free account.

Similar topics

6
5169
by: Frank Rachel | last post by:
So I can focus on the correct areas of research, I was wondering if someone could give me the .NET equivelents for this J2EE architecture: JSP's make calls to local JavaBean Controls. The controls do a JNDI lookup to invoke methods on EJB's. The EJB's use local Java classes, and these classes use JDBC to do database work. Example: Login.jsp contains "import xxx.LoginControl", and invokes the "login"
7
3347
by: Paul Sheer | last post by:
I need to automatically search and replace all fixed size buffer strcpy's with strncpy's (or better yet, strlcpy's) as a security and stability audit. The code base is large and it is not feasable to manually perform these changes. I would like perhaps a C++ parser that can automatically detect use of a strcpy to a buffer of fixed size. For instance, struct x { char member;
4
3247
by: Jon | last post by:
For the past month I have been porting a DirectX windows game to libSDL on linux, for right now I am working on the basic syntax of the game engine, I was having problems with opening, reading, and closeing of directories, I have fixed that though...who woulda thought that it would be open, read, and closedir()? Anyway, I am still working on the syntax, and I have been getting these errors when I compile: UEngine.cpp: In member...
10
9951
by: ios | last post by:
Hi Can someone tell me what is different between below case? strcpy(eventname, "MDCX_RSP"); and sprintf(eventname, "MDCX_RSP"); Thanks, Leon
302
18557
by: Lee | last post by:
Hi Whenever I use the gets() function, the gnu c compiler gives a warning that it is dangerous to use gets(). Is this due to the possibility of array overflow? Is it correct that the program flow can be altered by giving some specific calculated inputs to gets()? How could anyone do so once the executable binary have been generated? I have heard many of the security problems and other bugs are due to array overflows.
55
7091
by: Jake Thompson | last post by:
I need to copy a value into a char * field. I am currently doing this strcpy(cm8link.type,"13"); but I get an error of error C2664: 'strcpy' : cannot convert parameter 1 from 'const char' to 'char *'
20
2467
by: Snis Pilbor | last post by:
Whats the point of making functions which take arguments of a form like "const char *x"? It appears that this has no effect on the function actually working and doing its job, ie, if the function doesn't write to x, then it doesnt seem like the compiler could care less whether I specify the const part. Quite the opposite, if one uses const liberally and then later goes back and changes the functions, headaches will inevitably occur as...
4
9536
by: chikito.chikito | last post by:
1. Can someone tell me the difference between these two functions: void strcpy(char *s1, const char *s2) { while(*s1++ = *s2++) ; } //function prototype of strcpy follows char *strcpy(char *s1, const char *s2) // library function
5
3051
by: sam | last post by:
HI, Whats the meaning of this code:- char buff; memset(buff, 'A' , 100); sometimes we can place hex value in place of 'A' like 0x90c but how this code function actually. thanks in advance
77
8355
by: arnuld | last post by:
I have created my own implementation of strcpy library function. I would like to have comments for improvements: /* My version of "strcpy - a C Library Function */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h>
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9332
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.