Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

New to C(++): How do I used cmd-line params?

Name: Anonymous 2006-05-11 11:01

Hay guys!
I wated to program a little program that accepts parameters from the command-line. So I want to open it like

C:\whatever.exe param1 param2 ... paramn

So I wrote a bit.



#include <iostream>
#include <string>
using namespace std;
int main (int argc, string * argv[])
{
  int i;
  string ID;
  string action;
  string mode;
  string file;
  string real_file_name;
  int ret_val;
  ID             = argv[1];
  action         = argv[0];
  mode           = argv[2];
  file           = argv[2];
  real_file_name = argv[3];
//CODE
  return ret_val
}


But when I compile it, there are lots of errors... and they have something to do how I initialize those variables. (something with conversion from string * to basic_string)
argc works fine, but I expected it to :)

What's the problem here? Please explain it a bit or give me a good online-source where I can read this up!

And if you are asking: I'm using the command-line copiler from Microsoft... dunno if that'S important for you, though...

Name: Anonymous 2006-06-14 9:23

>>22
and it seems you didn't get it too :D

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List