Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Beginnerproblem argv splitting in cgi

Reply
Thread Tools

Re: Beginnerproblem argv splitting in cgi

 
 
Mike Wahler
Guest
Posts: n/a
 
      08-21-2003
Timo Meinger <(E-Mail Removed)> wrote in message
news:bi16pr$ink$02$(E-Mail Removed)-online.com...
>
> Hi!
> I am a C++ beginner and need help.
> Since hours i want to write a c++-cgi which gets 3 params,
> (1 char and 2 int).
>
> Excample-call:
> htt..../test.cgi?x,123,11
>
> Print out the argv of my main-method (with cout << ...)
> argv[0] = test.cgi
> argv[1] = x,123,11
>
> How can I get the values into this variables?
> char a = x
> int b = 123
> int c = 11
>
> thanks for your help!
> Timo


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>

int main(int argc, char **argv)
{
const char repl(',');
const char with(' ');

if(argc > 1)
{
std::string s(argv[1]);
std::replace(s.begin(), s.end(), repl, with);

std::istringstream iss(s);
char a(0);
int b(0);
int c(0);

iss >> a >> b >> c;

std::cout << "a == " << a << '\n'
<< "b == " << b << '\n'
<< "c == " << c << '\n';
}
else
std::cerr << "Need argument\n";

return 0;
}

-Mike



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
char **argv & char *argv[] jab3 C Programming 5 12-08-2004 08:15 AM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
difference(s) between char** argv and char* argv[] David C Programming 10 09-15-2003 06:58 AM
char **argv vs. char* argv[] Bret C Programming 21 09-03-2003 03:24 AM
sys.argv[0] - 'module' object has no attribute 'argv' =?ISO-8859-1?Q?Thomas_N=FCcker?= Python 0 06-30-2003 02:07 PM



Advertisments