Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-20-2003, 10:07 AM   #1
Registered: May 2001
Location: Louisville, Kentucky, USA
Distribution: RedHat ES
Posts: 120

Rep: Reputation: 15
Join an array of strings with C?

Is there a function to join an array of strings together, similar to Perl's join()?

Beyond, can anyone recommend a good online (heck, or even book) C reference? I don't want to keep coming by here to ask whether C has this function or that, but I can't find my answer via Google at the moment, so I am at a loss.

One of the biggest hurdles I am having with taking up C programming, is knowing which functions to use for which purposes. Like with Perl, I know what is what and where to look for it otherwise.

Of course, I suppose when I first started Perl I felt pretty much the same way, but I just don't remember that.
Old 06-20-2003, 10:49 AM   #2
LQ Newbie
Registered: Oct 2002
Location: istanbul
Distribution: redhat
Posts: 16

Rep: Reputation: 0
as far as i know there is no function in ansi C joining a multiple number of strings.
There is of course strcat which can concatenate two strings.You can find all the details in its man page.

All the same you can quite easily write your own. Just allocate enough space to hold all the strings, and strcat them all in a loop.

As a c programming resouce on linux I recommend
Old 06-20-2003, 11:03 AM   #3
Registered: May 2001
Location: Louisville, Kentucky, USA
Distribution: RedHat ES
Posts: 120

Original Poster
Rep: Reputation: 15
I found strcat before this post and started to write a join function (which I'll post here, though I'm sure someone has done better).

Thanks for pointing me to that resource.
Old 06-20-2003, 11:58 AM   #4
LQ Newbie
Registered: May 2003
Location: Georgia
Posts: 2

Rep: Reputation: 0
Actually, I would propose using strncat or something like that where you have to know and specify the number of bytes you are copying. Helps avoid those pesky buffer overflow problems that happen to windows code all the time.

I used to have a lovely C runtime reference, three ring binder, laid flat. Gosh I miss that Microsoft C5.1 compiler.

Mark "Getting misty eyed thinking back to my DOS days when life was simple." Johnson


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help using 'net join' to join a windows domain Wapo Linux - Networking 1 04-28-2006 03:30 AM
how to find duplicate strings in vertical column of strings markhod Programming 7 11-02-2005 05:04 AM
Initializing Array of Strings jrtayloriv Programming 10 02-03-2005 01:22 PM
PERL: Size of an array of an Array inspleak Programming 2 03-10-2004 03:24 PM
[C programming] sorting strings in an array miguetoo Programming 1 05-26-2003 02:48 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration