Computing.Net > Forums > Programming > c++ system() and variables

c++ system() and variables

Reply to Message Icon

Original Message
Name: Peaches
Date: July 18, 2006 at 03:16:16 Pacific
Subject: c++ system() and variables
OS: Linux
CPU/Ram: Pentium 4 and 256 mb
Model/Manufacturer: Intel
Comment:

I desparately need help!

The following command:
system("wget www.yahoo.com"); opens the page specified and now what I want to do is append a string(which is a variable thats being read from a file)

e.g
let's say the string being read is /birth so I want to append this string onto the domain name" www.yahoo.com "as a result I want to open the page www.yahoo.com/birth using the system command...so how can I do that?


Report Offensive Message For Removal

Response Number 1
Name: jdavidw13
Date: July 21, 2006 at 09:22:06 Pacific
Subject: c++ system() and variables
Reply: (edit)

To create dynamic system calls, just build the string first, before you pass it to system(). You can use the sprintf() function to write a string to a char buffer that formats like printf. For example,

/*read in your variable data, pretend you put it in var so var = "/birth" */
char buffer[50];
sprintf(buffer, "www.yahoo.com%s", var);
system(buffer);


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: c++ system() and variables

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software