LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-10-2010, 06:35 AM   #1
renuaseri
Member
 
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:-

"ftp://10.114.5.0/single.txt"

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");
//scanf("%s",name);
printf("remote ip is %s\r\n",remote ip) ;

return 0;
};

compile: gcc test.c -o test
run : ./test 10.114.5.0 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, 07:59 AM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

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

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

Code:
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, 08:11 AM   #3
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,672
Blog Entries: 29

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

Try snprintf !
 
  


Reply


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 10:53 AM
csh Shell Script: String Concatenation, how do i add a new line character? vxc69 Programming 1 05-04-2009 08:51 PM
C++ string object; add whitespace controll character sureshkellemane Programming 5 01-13-2009 07:31 PM
add String in awk an_sush Linux - Newbie 1 11-20-2008 11:42 AM
quick way to add string to a text file ufmale Linux - Newbie 1 03-11-2008 05:03 PM


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

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