473,699 Members | 2,907 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 2370

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

Similar topics

6
5164
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
3343
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
3243
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
9946
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
18489
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
7079
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
2449
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
9535
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
3036
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
8331
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
8704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8623
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
9187
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8894
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
7777
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6544
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5879
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();...
1
3071
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
2361
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.