473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"strncpy()" equilvant ?

hi,

i have a:
char[] record = new char[100];

In this i am loading a fixedlength record from a file.

What i would like to do, is to copy segments from this array into either
smaller strings or smaller arrays.

In C i would probably do something like this:

strncpy (field1, &record[0],10);

strncpy (field2, &record[10],8);

strncpy (field2, &record[18],20);

How can i do this in C# ?


Nov 16 '05 #1
1 8710

use Array.Copy method
-----Original Message-----
hi,

i have a:
char[] record = new char[100];

In this i am loading a fixedlength record from a file.

What i would like to do, is to copy segments from this array into eithersmaller strings or smaller arrays.

In C i would probably do something like this:

strncpy (field1, &record[0],10);

strncpy (field2, &record[10],8);

strncpy (field2, &record[18],20);

How can i do this in C# ?


.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
13
by: - Steve - | last post by:
I've been given a school assignment and while everything else is easy there's one topic I'm completley lost on. I've been given an ASCII file that looks like this. During start-up, the program...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
27
by: Shagy | last post by:
Greetings, I've been trying to find an equivant c funtion to the c++ copy function. Description: copy(char *cstring, size_t count, size_t offset); Copies "count" characters from a C-style...
188
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
6
by: AlexD_UK | last post by:
When I create a new C++ project of type "Class Library (.NET)", I am unable to then add the following line of code : using namespace std If I do, I get the following error on compilation :...
7
by: Olaf Baeyens | last post by:
I am testing VC++ 2005 and I get this warning: "warning C4996: 'strncpy' was declared deprecated" Does that mean that they might be phased out in VC++ 2006 or higher? Or does an alternative...
9
by: Ben Bacarisse | last post by:
I am porting a program from the Windows world to the Linux world. The source uses MS's new "safer" string functions such as: strcat_s(dest, size, source); but there are also calls such as: ...
7
by: Brice Rebsamen | last post by:
Reading the code from showkey.c (from package kbd) I found this type of code: char *m; m = "RAW"; See below for the complete code. How can this work? I would have used strdup, or allocation...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.