ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
/*
* This doesn't do any checks, so make damn sure everything
* fits into the destination string before-hand...
*/
char *noconcat(char *dest, char *src)
{
int len;
char *start;
len = strlen(dest);
start = dest + len;
strcpy(start, src);
return dest;
}
So whats diffrent with that code compared to the libc: strcat ? ..
$man strcat
NAME
strcat, strncat - concatenate two strings
SYNOPSIS
#include <string.h>
char *strcat(char *dest, const char *src);
DESCRIPTION
The strcat() function appends the src string to the dest string over-
writing the `\0' character at the end of dest, and then adds a termi-
nating `\0' character. The strings may not overlap, and the dest
string must have enough space for the result.
worldmagic:
If I wrote it correctly nothing.
I didn't look at the source for glibc so
I can't give a line by line comparison.
I figured cbjhawks is stumped on a hw
question. Otherwise his question doesn't
make much sense. If he's not looking to
avoid the string library function his question
breaks down into "How do I do this without
doing it?" and while he might be looking
for overloaded operators for the String class
he's still going to have to code it someplace.
Hehe, yeaps your code should be the same as the glibc (havent checked tho).. I guess his realy thinking of the overhead of creating new String objects. Cbjhawks please clearyfy your question =) .. If you thinking of how to avoid extra allocations, strcat from libc might work, if you try to avoid some HW/SW problem using your libc implementation use the suggested code from LogicG8
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.