Flexible string handling in Visual Studio 2008 C++
- by David
I'm slowly starting to get the hang of the _T stuff in Visual Studio 2008 c++, but a few things still elude me. I can see the benefit of the flexibility, but if I can't get the basics soon, I think I'll go back to the standard way of doing this - much less confusing.
The idea with the code below is that it scans the parameters for -d and then stores the text that follows that in the string variable fileDir. It also ignores any other parameters.
Any help is appreciated.
//Console application
Parameters::Parameters(int argc, _TCHAR* argv[])
{
_Tstring fileDir; // Is there some kind of _t variable to use here for a string?
for (int i = 0; i < argc; i = i + 1)
{
if (_tccmp(argv[i], _T("-d")) == 0) // this appeared to accept anything starting with -
{
i = i + 1;
fileDir = argv[i]
}
}
_tprintf("Parameter value found: %s\n", fileDir);
}