Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-10-2010, 05:35 AM   #1
Registered: Mar 2009
Posts: 39

Rep: Reputation: 15
how to add two string in c

hi all ,

i want to two add two sting so this give me a url in this format:-


for this i have written this code in "test.c"

#include <stdio.h>
#include <string.h>

int main ( int argc, char *argv[] )
if ( argc != 3 ) /* argc should be 2 for correct execution */
printf( "usage: %s filename", argv[0] );
char f1[]="ftp://";
char *remote_ip=argv[1]
char *upload_file=argv[2];

//printf("enter ip address");
printf("remote ip is %s\r\n",remote ip) ;

return 0;

compile: gcc test.c -o test
run : ./test single.txt

now plz tell me what are line i should add in this code.i have tryed by strcat but it is returning string in some bad format.

plz help me its very urgent...
Old 06-10-2010, 06:59 AM   #2
LQ 5k Club
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
1. Write more clearly.

2. Put code between [code] [/code] tags. It will look like this:

This is in code tags
3. Why didn't you put this in the Programming section of this forum? C programming has nothing to do with newbie Linux questions.
Old 06-10-2010, 07:11 AM   #3
Senior Member
Registered: Dec 2008
Posts: 4,680
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917

Try snprintf !


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
[SOLVED] How to Read a String and add it at the end in Unix funonnet Programming 7 06-11-2010 09:53 AM
csh Shell Script: String Concatenation, how do i add a new line character? vxc69 Programming 1 05-04-2009 07:51 PM
C++ string object; add whitespace controll character sureshkellemane Programming 5 01-13-2009 06:31 PM
add String in awk an_sush Linux - Newbie 1 11-20-2008 10:42 AM
quick way to add string to a text file ufmale Linux - Newbie 1 03-11-2008 04:03 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:06 AM.

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