Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

copy an array in c

Name: Anonymous 2007-03-12 22:30 ID:016HOAcL

I have a function, it accepts a char**, what is the quickest and most efficient way of making a local copy of the array in the function scope?

That is, i have , for example:

void funk(char **x){

char **b;

/*How do i make a separate copy of x to b?*/
}

Take pity on me internets, I'm a noob :) Thanks.

Name: Anonymous 2007-03-15 2:28 ID:2HoFjLyQ

>>31
Ok, cock sucker, that was me you were referring to. I love you smug bastards who think you know better than tried, tested and true technologies.

First of all you seem to be comparing a language that was designed as a "high level assembly" of sorts with a modern language with bounds checking and other such niceties. Stop.

Secondly, as >>32 said:
>only an idiot would store anything other than ascii or utf-8 text in a string.

Also if we're talking in terms of the O(n) length of a string a null-delimited string is much more memory efficient than the second-best alternative, that being storing an integer specifying how many characters long a string is (what is that, one byte vs. four bytes on most platforms?). The other advantage of a null-delimited string over having an integer specifying how long the string is is that the latter has a maximum length while the former has no such limit.

If you disagree with my last statement I challenge you to design a string structure more memory efficient than c-style strings. Because, y'know, memory/time efficiency is kind of what C is all about and I'm sure somebody smarter than you or I would have figured out something better, if it existed, long ago.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List