|
From: Teodorescu C. <te...@xt...> - 2002-11-05 07:44:31
|
Jerry van Dijk wrote:
>While trying out g++ 3.2, I did the following:
>
>-----------------------------------------------------------------
>#include <vector>
>#include <string>
>
>int main(int argc, char* argv[])
>{
> // std::vector<std::string> arguments(argv[0], argv[argc]);
> std::vector<std::string> arguments;
>
Your *arguments* vector has length 0 you must resize it to argc
or use
arguments.pushpack(argv[i]);
It's simple read :
http://www.oopweb.com/CPP/Documents/STLGuide/VolumeFrames.html
> for (int i=0; i<argc; i++)
> arguments[i]=argv[i];
>}
>-----------------------------------------------------------------
>
>which compiles Ok, but segfaults on execution. I did a lot of headscratching
>but I cannot figure out why. arguments[i] evaluates to a string type, argv[i]
>to effectively a const char*, and string has an const char* constructor.
>
>Help would be apreciated.
>
>
>
|