By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!> Sscanf(L"", L"%s", szText);
>
> returns 1. Is it by design? If so, can it be used to advantage? The
> comparable swscanf() statement returns 0 and the comparable sscanf()
> statement returns -1.
>vefatica wrote:
>
>
>---Quote---
>> Sscanf(L"", L"%s", szText);
>>
>> returns 1. Is it by design? If so, can it be used to advantage? The
>> comparable swscanf() statement returns 0 and the comparable sscanf()
>> statement returns -1.
>---End Quote---
>WAD. It's not returning 0 arguments, it's returning 1 empty string.
> On Sun, 14 Sep 2008 12:50:38 -0500, rconn <> wrote:
>
>
> Quote:
> >vefatica wrote:
> >
> >
> >---Quote---
> >> Sscanf(L"", L"%s", szText);
> >>
> >> returns 1. Is it by design? If so, can it be used to advantage? The
> >> comparable swscanf() statement returns 0 and the comparable sscanf()
> >> statement returns -1.
> >---End Quote---
> >WAD. It's not returning 0 arguments, it's returning 1 empty string.
>
> How is it that this one returns 2?
>
> Sscanf(L"", L"%s %s", szStr1, szStr2);
>> How is it that this one returns 2?
>>
>> Sscanf(L"", L"%s %s", szStr1, szStr2);
>---End Quote---
>Because it returns *two* empty strings.
>
>If you want the swscanf behavior, use that instead. I wrote Sscanf
>because swscanf and sscanf didn't meet my particular needs. (I wanted
>the strings to always be initialized, which swscanf and sscanf wouldn't do.)
> On Sun, 14 Sep 2008 15:23:52 -0500, rconn <> wrote:
>
>
> Quote:
> >> How is it that this one returns 2?
> >>
> >> Sscanf(L"", L"%s %s", szStr1, szStr2);
> >---End Quote---
> >Because it returns *two* empty strings.
> >
> >If you want the swscanf behavior, use that instead. I wrote Sscanf
> >because swscanf and sscanf didn't meet my particular needs. (I wanted
> >the strings to always be initialized, which swscanf and sscanf
> wouldn't do.)
>
> The only clue I had as to how Sscanf() works was TakeCmd.h's
> Are you saying the string will be initialized if Sscanf() reaches the point
> where it's looking for something to put in it?
>
> I want to parse an option like
>
> /X[=n[,str]]
>
> which I've isolated. If "/X" is found, how would you proceed?
>I have no idea what you want to do here ...
> On Sun, 14 Sep 2008 20:07:12 -0500, rconn <> wrote:
> Quote:
> >I have no idea what you want to do here ...
>
> Suppose you had a command with syntax
>
> COMMAND [/X[=n[,str]]] ...
>
> an INT where n should go, a WCHAR[] where str should go, and default
> values for
> both (to be used if values aren't spec'd). Suppose you've isolated a command
> line argument (say with NthArgument) and you want to see if it's the
> "/X" option
> and if it is, do all the right things. What would you recommend? I can
> always
> stand to learn from an expert.
>vefatica wrote:
>
>
>---Quote---
>> On Sun, 14 Sep 2008 20:07:12 -0500, rconn <> wrote:
>> Quote:
>> >I have no idea what you want to do here ...
>>
>> Suppose you had a command with syntax
>>
>> COMMAND [/X[=n[,str]]] ...
>>
>> an INT where n should go, a WCHAR[] where str should go, and default
>> values for
>> both (to be used if values aren't spec'd). Suppose you've isolated a command
>> line argument (say with NthArgument) and you want to see if it's the
>> "/X" option
>> and if it is, do all the right things. What would you recommend? I can
>> always
>> stand to learn from an expert.
>---End Quote---
>If you've extracted the argument with NthArgument, you won't even see
>the ",str" part because the "," will be treated as a delimiter. You'd
>either have to parse the line an argument at a time (saving the previous
>state) or use something like :
>
> Sscanf( line, L"=%d,%s", &n, str );
>
> I want to parse an option like
>
> /X[=n[,str]]
>
> which I've isolated. If "/X" is found, how would you proceed?
>---Quote---
>>
>> I want to parse an option like
>>
>> /X[=n[,str]]
>>
>> which I've isolated. If "/X" is found, how would you proceed?
>---End Quote---
>For what it's worth, my approach would be: