f



printf("%d%d%d")

Dear all,

Consider:

include <stdio.h>
int main(void)
{
    printf("%d%d%d");
    return (0);
}

I'm having a bad time trying to explain someone (elsewhere) why the 
aforementioned code is a constraint violation and thus requires a 
(implementation defined) warning.

I have cited the part of the standard about stdio.h, where they 
explicitly state that "If there are insufficient arguments for the 
format, the behavior is undefined."

He's arguments have been:
- a undefined behavior doesn't imply a constraint violation
   -> I can't word out why he's wrong
- gcc doesn't give any warnings using -std=c99
   -> I'm lost... I have told him that GCC includes a warning switch 
(-Wformat) which actually gives a warning for the code above, and that's 
fine since the standard just says that the implementation has to give a 
warning, but doesn't dictate how, using which flags, ....

Please, do you have any other wording / examples / way to explain this 
person why the code is a constraint violation, why it does require a 
warning and why GCC is ok by issuing this warning with -Wformat?


Thanks a lot!
-- 
Pietro Cerutti
0
Pietro
7/30/2008 8:24:19 AM
comp.lang.c 30657 articles. 5 followers. spinoza1111 (3246) is leader. Post Follow

12 Replies
669 Views

Similar Articles

[PageSpeed] 15

Pietro Cerutti wrote:
) Consider:
)
) include <stdio.h>
) int main(void)
) {
)     printf("%d%d%d");
)     return (0);
) }

Undefined behaviour, yes.  Reading on...

) I'm having a bad time trying to explain someone (elsewhere) why the 
) aforementioned code is a constraint violation and thus requires a 
) (implementation defined) warning.
)
) I have cited the part of the standard about stdio.h, where they 
) explicitly state that "If there are insufficient arguments for the 
) format, the behavior is undefined."
)
) He's arguments have been:
) - a undefined behavior doesn't imply a constraint violation
)    -> I can't word out why he's wrong

That may be because he is right.
Otherwise, i = i++ would have to generate a diagnostic as well.

) - gcc doesn't give any warnings using -std=c99
)    -> I'm lost... I have told him that GCC includes a warning switch 
) (-Wformat) which actually gives a warning for the code above, and that's 
) fine since the standard just says that the implementation has to give a 
) warning, but doesn't dictate how, using which flags, ....

If the standard sais that the implementation has to give a diagnostic,
that means you *don't* have to have any extra flags to give said
diagnostic.  Just the flags to make it standards conforming.

So he's right again.

) Please, do you have any other wording / examples / way to explain this 
) person why the code is a constraint violation, why it does require a 
) warning and why GCC is ok by issuing this warning with -Wformat?

"You were right, it's not a constraint violation." would be adequate. ;-)


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
0
willem (1478)
7/30/2008 8:36:04 AM
Willem wrote:
> Pietro Cerutti wrote:
> ) Consider:
> )
> ) include <stdio.h>
> ) int main(void)
> ) {
> )     printf("%d%d%d");
> )     return (0);
> ) }
> 
> Undefined behaviour, yes.  Reading on...
> 
> ) I'm having a bad time trying to explain someone (elsewhere) why the 
> ) aforementioned code is a constraint violation and thus requires a 
> ) (implementation defined) warning.
> )
> ) I have cited the part of the standard about stdio.h, where they 
> ) explicitly state that "If there are insufficient arguments for the 
> ) format, the behavior is undefined."
> )
> ) He's arguments have been:
> ) - a undefined behavior doesn't imply a constraint violation
> )    -> I can't word out why he's wrong
> 
> That may be because he is right.
> Otherwise, i = i++ would have to generate a diagnostic as well.

It does, using at least -Wsequence-point.
> 
> ) - gcc doesn't give any warnings using -std=c99
> )    -> I'm lost... I have told him that GCC includes a warning switch 
> ) (-Wformat) which actually gives a warning for the code above, and that's 
> ) fine since the standard just says that the implementation has to give a 
> ) warning, but doesn't dictate how, using which flags, ....
> 
> If the standard sais that the implementation has to give a diagnostic,
> that means you *don't* have to have any extra flags to give said
> diagnostic.  Just the flags to make it standards conforming.

Sais who? The standard says "in an implementation defined manner". It 
doesn't dictate any further. Am I missing anything?


> SaSW, Willem


-- 
Pietro Cerutti
0
Pietro
7/30/2008 8:39:37 AM
Pietro Cerutti wrote:
) Willem wrote:
)> That may be because he is right.
)> Otherwise, i = i++ would have to generate a diagnostic as well.
)
) It does, using at least -Wsequence-point.

Is there a warning flag for *all* undefined behaviour ?
Note the following piece of undefined behaviour code:

 #include <stdio.h>
 int main(void)
 {
    char x[20] = "one one one one";
    char y[20] = "two two two two";
    int i = 0;
    for (i = 0; i < 40; i++)
	x[i] = 'x';
    printf("%s, %s",x , y);
    return 0;
 }

(Interestingly, on my implementation, this has different results when
 compiled with or without optimization (gcc 4.2.1 for the record))

)> 
)> ) - gcc doesn't give any warnings using -std=c99
)> )    -> I'm lost... I have told him that GCC includes a warning switch 
)> ) (-Wformat) which actually gives a warning for the code above, and that's 
)> ) fine since the standard just says that the implementation has to give a 
)> ) warning, but doesn't dictate how, using which flags, ....
)> 
)> If the standard sais that the implementation has to give a diagnostic,
)> that means you *don't* have to have any extra flags to give said
)> diagnostic.  Just the flags to make it standards conforming.
)
) Sais who? The standard says "in an implementation defined manner". It 
) doesn't dictate any further. Am I missing anything?

You're making a big leap when you interpret "in an implementation defined
manner" as "you may need to specify additional options".

It simply means that the form of the diagnostic is up to the
implementation.  But it *must* issue *something*.


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
0
willem (1478)
7/30/2008 8:55:45 AM
Pietro Cerutti <gahr_SPAM_gahr_ME_ch> said:
> Willem wrote:
<snip>

>> Otherwise, i = i++ would have to generate a diagnostic as well.
> 
> It does, using at least -Wsequence-point.

It's allowed to. It just doesn't *have* to.  The behaviour (if indeed there 
is any) of code that contains a constraint violation or syntax error is 
undefined - all cats and dogs are animals - but undefined behaviour is not 
sufficient on its own to qualify as a constraint violation or syntax error 
requiring a diagnostic message - not all animals are cats or dogs.

<snip>

>> If the standard sais that the implementation has to give a diagnostic,
>> that means you *don't* have to have any extra flags to give said
>> diagnostic.  Just the flags to make it standards conforming.
> 
> Sais who? The standard says "in an implementation defined manner". It
> doesn't dictate any further. Am I missing anything?

Yes. Firstly, if the implementation is not invoked in conforming mode 
(whether it's through flags or semaphore messages across the mountains or 
telepathy or is simply the default invocation mode for the 
implementation), we're not discussing C, we're off-topic, and the Standard 
is meaningless within the context of the discussion. So we're stuck with 
conforming mode. Given conforming mode, if a particular translation unit 
contains any syntax errors or constraint violations, at least one 
diagnostic message is *required*. In that and any other circumstance, any 
other diagnostic messages are *allowed*.

-- 
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
0
rjh (10791)
7/30/2008 9:03:27 AM
Richard Heathfield wrote:
> Pietro Cerutti <gahr_SPAM_gahr_ME_ch> said:
>> Willem wrote:
> <snip>
> 
>>> Otherwise, i = i++ would have to generate a diagnostic as well.
>> It does, using at least -Wsequence-point.
> 
> It's allowed to. It just doesn't *have* to.  The behaviour (if indeed there 
> is any) of code that contains a constraint violation or syntax error is 
> undefined - all cats and dogs are animals - but undefined behaviour is not 
> sufficient on its own to qualify as a constraint violation or syntax error 
> requiring a diagnostic message - not all animals are cats or dogs.

Oh I see.. so I was wrong in thinking that UB implies constraint 
violation. One point is not clear to me, which I would kindly ask you to 
clarify...

Given this:
3.8
1   constraint
     restriction, either syntactic or semantic, by which the exposition
     of language elements is to be interpreted

How can a call to printf("%d%d%d") not fail to conform to a semantic 
exposition of the language, in this case of the standard function?

That is why I thought that such a call was a constraint violation, in 
the first place.



-- 
Pietro Cerutti
0
Pietro
7/30/2008 9:11:28 AM
Pietro Cerutti <gahr_SPAM_gahr_ME_ch> wrote:

> Richard Heathfield wrote:
>> Pietro Cerutti <gahr_SPAM_gahr_ME_ch> said:
>>> Willem wrote:
>> <snip>
>> 
>>>> Otherwise, i = i++ would have to generate a diagnostic as well.
>>> It does, using at least -Wsequence-point.
>> 
>> It's allowed to. It just doesn't *have* to.  The behaviour (if indeed
>> there is any) of code that contains a constraint violation or syntax
>> error is undefined - all cats and dogs are animals - but undefined
>> behaviour is not sufficient on its own to qualify as a constraint
>> violation or syntax error requiring a diagnostic message - not all
>> animals are cats or dogs.
> 
> Oh I see.. so I was wrong in thinking that UB implies constraint
> violation. One point is not clear to me, which I would kindly ask you
> to clarify...
> 
> Given this:
> 3.8
> 1   constraint
>      restriction, either syntactic or semantic, by which the
>      exposition of language elements is to be interpreted
> 
> How can a call to printf("%d%d%d") not fail to conform to a semantic
> exposition of the language, in this case of the standard function?

This is because printf is a variadic function and it is not always
possible for the compiler to check whether you have supplied the
corresponding arguments for any format specifiers in your format
string. Therefore calling printf with insufficient arguments is
undefined behaviour but not a constraint violation, so a diagnostic[s]
is allowed, but not necessary.

> That is why I thought that such a call was a constraint violation, in
> the first place.

0
santosh.k83 (3969)
7/30/2008 9:32:24 AM
Pietro Cerutti <gahr_SPAM_gahr_ME_ch> wrote:

> Dear all,
> 
> Consider:
> 
> include <stdio.h>
> int main(void)
> {
>     printf("%d%d%d");
>     return (0);
> }
> 
> I'm having a bad time trying to explain someone (elsewhere) why the 
> aforementioned code is a constraint violation and thus requires a 
> (implementation defined) warning.

That would be because it isn't and doesn't.

> I have cited the part of the standard about stdio.h, where they 
> explicitly state that "If there are insufficient arguments for the 
> format, the behavior is undefined."

Quite. Undefined, not:

  Constraint
    1. There shall be sufficient arguments for the format.


> He's arguments have been:
> - a undefined behavior doesn't imply a constraint violation
>    -> I can't word out why he's wrong

He's right.

Richard
0
rlb (4118)
7/30/2008 9:43:28 AM
Pietro Cerutti <gahr_SPAM_gahr_ME_ch> said:

<snip>

> One point is not clear to me, which I would kindly ask you to
> clarify...
> 
> Given this:
> 3.8
> 1   constraint
>      restriction, either syntactic or semantic, by which the exposition
>      of language elements is to be interpreted
> 
> How can a call to printf("%d%d%d") not fail to conform to a semantic
> exposition of the language, in this case of the standard function?

Rather than repeat santosh's perfectly correct answer, I'll give you a 
slightly different perspective.

You have quite rightly spotted that C99 defines "constraint", but I wonder 
whether you have noticed that each and every constraint is documented at 
the head of the relevant section, under a subsection entitled, in each 
case, "Constraints". It is violation of these constraints that requires a 
syntax error. So - if we believe that printf("%d%d%d") violates a 
constraint, it is reasonable to ask /which/ constraint is violated. I 
can't find any constraint that printf("%d%d%d") violates. Can you?

-- 
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
0
rjh (10791)
7/30/2008 1:12:28 PM
Richard Heathfield wrote:
> Pietro Cerutti <gahr_SPAM_gahr_ME_ch> said:
> 
> <snip>
> 
>> One point is not clear to me, which I would kindly ask you to
>> clarify...
>>
>> Given this:
>> 3.8
>> 1   constraint
>>      restriction, either syntactic or semantic, by which the exposition
>>      of language elements is to be interpreted
>>
>> How can a call to printf("%d%d%d") not fail to conform to a semantic
>> exposition of the language, in this case of the standard function?
> 
> Rather than repeat santosh's perfectly correct answer, I'll give you a 
> slightly different perspective.
> 
> You have quite rightly spotted that C99 defines "constraint", but I wonder 
> whether you have noticed that each and every constraint is documented at 
> the head of the relevant section, under a subsection entitled, in each 
> case, "Constraints". It is violation of these constraints that requires a 
> syntax error. So - if we believe that printf("%d%d%d") violates a 
> constraint, it is reasonable to ask /which/ constraint is violated. I 
> can't find any constraint that printf("%d%d%d") violates. Can you?
> 

Given your explanation, no, I can't. Indeed, I didn't notice that 
constraints were explicitly stated in their own subsections. Thanks!

-- 
Pietro Cerutti
0
Pietro
7/30/2008 1:17:31 PM
Richard Heathfield said:

<snip>

> It is violation of these
> constraints that requires a syntax error.

s/syntax error/diagnostic message/furrfu!

-- 
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
0
rjh (10791)
7/30/2008 1:21:06 PM
On 30 Jul, 10:11, Pietro Cerutti <gahr_SPAM_gahr_ME_ch> wrote:
> Richard Heathfield wrote:
> > Pietro Cerutti <gahr_SPAM_gahr_ME_ch> said:
> >> Willem wrote:

> >>> Otherwise, i = i++ would have to generate a diagnostic as well.
> >> It does, using at least -Wsequence-point.
>
> > It's allowed to. It just doesn't *have* to.  The behaviour (if indeed there
> > is any) of code that contains a constraint violation or syntax error is
> > undefined - all cats and dogs are animals - but undefined behaviour is not
> > sufficient on its own to qualify as a constraint violation or syntax error
> > requiring a diagnostic message - not all animals are cats or dogs.
>
> Oh I see.. so I was wrong in thinking that UB implies constraint
> violation. One point is not clear to me, which I would kindly ask you to
> clarify...
>
> Given this:
> 3.8
> 1   constraint
>      restriction, either syntactic or semantic, by which the exposition
>      of language elements is to be interpreted
>
> How can a call to printf("%d%d%d") not fail to conform to a semantic
> exposition of the language, in this case of the standard function?
>
> That is why I thought that such a call was a constraint violation, in
> the first place.

it's impossible to diagnose in general. (at compile time that is).

/* print.c */
#include <stdio.h>

int main(void)
{
    char s [80];
    fgets (s, sizeof s, stdin);
    printf (s);
    return 0;
}

print %d%d%d

in general the C standard says things have Undefined Behaviour
if they cannot be easily detected at compile time. UB does *not*
require a diagnostic and is *not* a constraint violation.

gcc can diagnose *some* printf/scanf errors but it is
not required to. Some compilers don't do any checks
on format strings.


--
Nick Keighley



0
7/30/2008 1:30:03 PM
>include <stdio.h>
>int main(void)
>{
>    printf("%d%d%d");
>    return (0);
>}

>I have cited the part of the standard about stdio.h, where they 
>explicitly state that "If there are insufficient arguments for the 
>format, the behavior is undefined."
>
>He's arguments have been:
>- a undefined behavior doesn't imply a constraint violation
>   -> I can't word out why he's wrong

>- gcc doesn't give any warnings using -std=c99
>   -> I'm lost... I have told him that GCC includes a warning switch 
>(-Wformat) which actually gives a warning for the code above, and that's 
>fine since the standard just says that the implementation has to give a 
>warning, but doesn't dictate how, using which flags, ....

From the standard's point of view, every combination of compiler
flags that affects warning messages, code generation, or other
requirements imposed by the standard is a different implementation.
There is not one implementation of GCC.  Any given copy likely has
more than 2**200 different implementations, selected with compiler
flags.  And that doesn't include different versions or different
target machines.  However, you only have to be concerned with the
ones claimed to be standards-conforming.

>Please, do you have any other wording / examples / way to explain this 
>person why the code is a constraint violation, 

It isn't.

>why it does require a 
>warning 

It doesn't.

>and why GCC is ok by issuing this warning with -Wformat?

Two implementations that differ only in the -Wformat flag are equally
conforming.  The warning isn't required.  However, gcc is permitted
to issue a warning that is not required anyway (and regardless of
how factually wrong, stupid, irrelevant, or pointless it is).
Examples:

warning:  it's Tuesday.
warning: division by 3 (even if program contains no division)
warning: program does not contain a license.

0
7/30/2008 6:18:18 PM
Reply:

Similar Artilces:

["a", "b", "c", "d"] to "a, b, c, d"?
I want to process each element of an array, but the last element should be handled special. Here is an example: def p_ary(ary) str = "" ary.each do |elem| str << elem << ", " end str.chomp!(", ") str end so p_ary(["a", "f", "x", "test"]) produces "a, f, x, test". The code works, but isn't there an easier and more general way for this behaviour? martinus On Tue, 06 Apr 2004 04:23:22 -0700, Martin wrote: > I want to process each element of an array, but the last ele...

printf("%d,%d,%d", a, a++, a++)
int main(void) { int a = 3; printf("%d, %d, %d", a, a++, a++); } with Gcc, the output is "5 4 3", I just confused. Xiaofeng Ye wrote: > int main(void) > { > int a = 3; > printf("%d, %d, %d", a, a++, a++); > } > > with Gcc, the output is "5 4 3", I just confused. Question 3.2 of the faq will be elucidating. See: http://www.eskimo.com/~scs/C-faq/q3.2.html - Al Bowers Tampa, Fl USA mailto: xabowers@myrapidsys.com (remove the x to send email) http://www.geocities.com/abowers822/ In article <cplkgg$17pq$1@mail.cn99.com>...

the question about: printf("%d\t%d\t%d\t%d\t%d\t%d\n",i,++i,--i,i--,i++,-i--);
int i=8; printf("%d\t%d\t%d\t%d\t%d\t%d\n",i,++i,--i,i--,i++,-i--); printf("%d\n", i); why the results is: 8 8 7 8 8 -8 7 How to explain? WeiWangJi wrote: > int i=8; > printf("%d\t%d\t%d\t%d\t%d\t%d\n",i,++i,--i,i--,i++,-i--); > printf("%d\n", i); > > why the results is: > > 8 8 7 8 8 -8 > 7 > > How to explain? > There is no explaination. Because you modify the same varaible more than once in the same function call your code is illegal, and it's be...

Transform string : "c;b;a;e;d" -> "a;b;c;d;e" ?
Thank's for your help ! Indrid On Mon, 11 Jul 2005 22:47:26 -0400, "Indrid Colt" <indrid@colt.com> wrote: Well, you could use the Split function to create an array with 5 elements. Then use any suitable sorting algorithm to sort these items. Then use the Join function to stitch the elements back together. -Tom. >Thank's for your help ! > > >Indrid > Tom van Stiphout <no.spam.tom7744@cox.net> wrote in news:fkc6d1thuadliq28absbqrjpc535d4m1p0@4ax.com: > On Mon, 11 Jul 2005 22:47:26 -0400, "Indrid Colt" > <indrid@colt.com> wrote: > > Well, you could use the Split function to create an array with 5 > elements. Then use any suitable sorting algorithm to sort these > items. Then use the Join function to stitch the elements back > together. For a case where the values are all one character, why not just use a ReverseString() function like the one posted after my sig? -- David W. Fenton http://www.bway.net/~dfenton dfenton at bway dot net http://www.bway.net/~dfassoc Public Function ReverseString(strInput As String) As String Dim i As Integer Dim tmpString As String Dim tmpOutput As String tmpString = strInput For i = 1 To Len(strInput) tmpOutput = tmpOutput & Right(tmpString, 1) tmpString = Left(tmpString, Len(tmpString) - 1) Next i ReverseString = tmpOutput End Function David W. Fenton wrote: > For a case where...

scanf("%d. %d. %d",&d,&m,&y);
why scanf("%d. %d. %d",&d,&m,&y); is NOT reading the i/p 22 4 1972 correctly, whereas it is reading the i/p 22. 4. 1972 correctly ?. Is it because of the dot in the format string of scanf ? sophia wrote: > why scanf("%d. %d. %d",&d,&m,&y); > > is NOT reading the i/p 22 4 1972 correctly, > whereas it is reading the i/p 22. 4. 1972 correctly ?. > > Is it because of the dot in the format string of scanf ? Yes, why did you put them there if you didn't expect them in the input? -- Ian Collins. sophia wrote: > >...

AC97 Mixer: What is "C" and "D"
I got a program called "AC97 Mixer" installed, and on the control panel, under "3D" there are sliders for "C" and "D". What do these sliders alter? Certainly I get a fuller sound by having "3D" activated. TIA. Rich. ...

Printf("%d")
Hi all, Why does a printf("%d") statement prints this as output and when I do printf("%c") it doesn't print anything. -13361016 Any help would be appreciated. Thanks, MJ In article <1128916418.735484.182050@g14g2000cwa.googlegroups.com>, geek <metri.jain@gmail.com> wrote: >Why does a printf("%d") statement prints this as output and when I do >printf("%c") it doesn't print anything. >-13361016 It is undefined behaviour to have a format element for which the parameter is missing or not of the matching type. What your...

Interpreting "(.*?)" and "(?:\d+ [.]?)" in REs
Hi All, I want to extract numbers from records with a leading string of period- separated numbers. I got great responses to this on the thread http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/a811f41d733125f3#, including the program below (stripped of all error handling). My question is the meaning of a couple of constructs in the regular expressions (and where I can find on-line documentation for them, if possible): 1. "(.*?)", or specifically, the "?" in that expression. 2. "(?:\d+ [.]?)", or the two question marks in this case. Thanks in ad...

"Guardian Error" occured on tcp/ip operation"receive_tcp_ru_nowait" in C:D
I am trying to send file from mainframe to tandem via connect direct and getting error: Guardian Error "Guardian Error" occured on tcp/ip operation"receive_tcp_ru_nowait" in C:D Function "Recv_nw" netmap, LU and secure+ are all fine. Is there anything wrong with TCP process ? The message id is: GTCP001I RC 8 FDBK 1 What Guardian error number your application received? Any idea? That is the error.message I am receiving in ndmcom sel stat. No guardian error number :( On Wednesday, September 5, 2012 6:14:38 PM UTC+5:30, ChinmaY wrote: > That is the error.message I am receiving in ndmcom sel stat. No guardian error number :( Clearly the recv_nw is failing and I thought your NDMLOG will at least reveal some more info. What else? Let me think for a while and then I will get back. ChinmaY wrote: > I am trying to send file from mainframe to tandem via connect direct and getting error: > Guardian Error "Guardian Error" occured on tcp/ip operation"receive_tcp_ru_nowait" in C:D > Function "Recv_nw" > > netmap, LU and secure+ are all fine. Is there anything wrong with TCP process ? I know nothing about Connect Direct, so maybe my opinion is out of order, but it sure seems to me that Connect Direct is rather deficient in this situation in that it reports the TCP/IP operation and function within Connect Direct that is getting the error, but neglects to report the actual error number....

I7B"d The Arcade Room Rocks ! I7B"d
This site has tons of games for fun! Visit the arcade room for excitement at http://www.gabbyinc.net ! Also has plenty of free games to enjoy! So pass it on... ]TreN ...

Convert 1-D into 2-D and matrix in "for loop"
Any tips on how to convert a 1-D data series into 2-D? Say, a data series sized 100,000x1. We need to get a mean value for every 10. Coz the size is very big, so we would like methods other than loops. I think one way is convert the 1-D series into 10x10,000, so that mean() can be used for each row. But how? And how to use matrix loop or something like that? Say, x=[1 2 3 4;5 6 7 8;9 10 11 12], we would like to get y(1)=[1 2 3 4], y(2)=[5 6 7 8], y(3)=[9 10 11 12]. for i=1:3 y(i)=... end ? Many thanks in advace. On Thu, 09 Nov 2006 10:34:47 -0500, seb wrote: > Any tips on how to conver...

AUD_CHAN=`mplayer -vo null -ao null -frames 0 -v dvd://1 2>/dev/null| grep "en aid:" | cut -d ":" -f 5 | tr -d ' '`
Look how easy it is to use Linux ! I love it! DFS <nospam@nospam.com> wrote: > Look how easy it is to use Linux ! > > I love it! Indeed, however if person had read the mplayer manpage, that person would have found -alang (the option just after -aid): EXAMPLE: mplayer dvd://1 -alang hu,en Chooses the Hungarian language track on a DVD and falls back on English if Hungarian is not available. mplayer -alang jpn example.mkv Plays a Matroska file in Japanese. So if you want to troll, please do some research before copying stuff you don't ac...

printf("%d",float)
Hi all, I just came across the following program: #include <stdio.h> int main() { float a = 12.5; printf("%d\n", a); printf("%d\n", *(int *)&a); return 0; } The program prints 0 and 1095237362. However, in my opinion it should print 12 at both the places. Can anybody tell me where I am wrong? candy_init@yahoo.com said: > Hi all, > I just came across the following program: > > #include <stdio.h> > int main() > { > float a = 12.5; > printf("%d\n", a); > printf("%d\n", *(int *...

int a=printf("%d\n",a);
does the expression int a=printf("%d\n",a); implementation dependent ? I supposed it would produced the result 2, but i got 4206596 (result may vary on your machine), i wonder if the value produced was a memory address and anything special with this expression ? sugaray wrote: > does the expression int a=printf("%d\n",a); implementation dependent ? No, it's undefined, since `a' hasn't been initialized at the time you pass its value to printf(). Don't do that. > I supposed it would produced the result 2 Why? Jeremy. Jeremy Yallop <jeremy@jdyal...

How to generate "a, b, c, and d"?
I've got a list, ['a', 'b', 'c', 'd']. I want to generate the string, "a, b, c, and d" (I'll settle for no comma after 'c'). Is there some standard way to do this, handling all the special cases? [] ==> '' ['a'] ==> 'a' ['a', 'b'] ==> 'a and b' ['a', 'b', 'c', 'd'] ==> 'a, b, and c' It seems like the kind of thing django.contrib.humanize would handle, but alas, it doesn't. On 15/12/2011 16:48, Roy Smith wrote: > I've got a...

/dev/mouse : No such device
Hi, I'm using Redhat 7.3... When I run "/etc/rc.d/r3.d/S85gpm start" , I met following messages. /dev/mouse : No such device My mouse is ps2 and I can see /dev/mouse file . it is linked /dev/input/mice. What do I check to work it? ( becase of mouse device, I can't start X-windows ). Thansk. additionally , displayed message is oops() invoked from gpm.c (978). > Hi, > I'm using Redhat 7.3... > When I run "/etc/rc.d/r3.d/S85gpm start" , I met following messages. > > /dev/mouse : No such device > > My mouse is ps2 and I can see /dev/mouse file . it is linked > /dev/input/mice. > > What do I check to work it? > ( becase of mouse device, I can't start X-windows ). > > Thansk. > > On Mon, 22 Jan 2007 16:25:46 +0900, kerneloops <rambo88@gmail.com> wrote: > > > Hi, > I'm using Redhat 7.3... > When I run "/etc/rc.d/r3.d/S85gpm start" , I met following messages. > > /dev/mouse : No such device > > My mouse is ps2 and I can see /dev/mouse file . it is linked > /dev/input/mice. > > What do I check to work it? > ( becase of mouse device, I can't start X-windows ). > Redhat 7.3 is very old. You should try "Redhat 15", better known as Fedora Core 6. With a 2.4 kernel and a PS2 mouse, /dev/mouse s...

x-post (in c.d.o.misc) "returning into" in Pro C
Cross-posted on comp.databases.oracle.misc. Hi, This has been driving me nuts and in all my Googling I haven't yet been able to find if I just can't do it or my syntax/variables are wrong. I've got a Pro C query and I want to do a "returning into" to retrieve a newly inserted Oracle sequence number (so I can have it in a variable and use that sequence number to associate detail rows for the inserted header row). The Pro C guide gives the syntax but also mentions that it's available in dynamic SQL - but doesn't say if it's **only** available that way. Also, the guide mentions "host" variables, and I'm assuming that's the same as the bind vars I'm using - am I wrong? Here's an edited version of the code: EXEC SQL BEGIN DECLARE SECTION; char n_seq_number [21] = {NULL}; EXEC SQL VAR n_seq_number IS STRING EXEC SQL END DECLARE SECTION; EXEC SQL INSERT INTO orders (wh, ord_no, customer, ord_date line_number) VALUES(:WH_ID, :ord_no, :customer, sysdate, my_seq.nextval) RETURNING to_char(line_number) INTO :n_seq_number; the number is NUMBER(20), so I can't use integers. Although hte sequence is only up to 7 long, so I tried an int bind variable and still have problems. Oh, sorry, the problem is the first time it executes this (on UNIX (AIX)), I get a segmentation fault and an undecipherabl...

extracting D from 1 / D*D
Hi Folks, Incredibly busy summer here, so before burning my brain cells, Googling or -worst- digging in my very dusty math courses, I submit this question to the DSP experts who usually float around, hoping some aren't at the beaches ;-) How would you extract D from a X = K / (D * D) value (16 bits) ? - in a small FPGA indeed, which has no embedded mult (but a mult could be synthesized) - please don't answer to synthesize sqrt(1/x) ! - I have lots of clock cycles available to compensate the lack of FPGA resources. - I would like to avoid a Piece-Wise Linear estimator if possible ...

Passage en un clic d'une requete "listing" aux infos d'un enregistrement choisi
Bonjour � tous, Je d�veloppe une base traitant des candidatures pour des jobs. J'ai cr�er des requetes me donnant des listings d'individus selon des crit�res, et je d�sire pouvoir acc�der directement aux informations globale sur un individu choisi (dont la ligne est active). La requete d'origine et le formulaire d'information globale sont bas� sur la m�me base Candidat. Je pense qu'il faut utiliser la fonction Where, mais �tant autodidacte je n'ai pas la bonne syntaxe et mes lignes g�n�re des erreurs. Pourrait-on me donner quelques pistes, ou m�me des solutions ? Je travaille sur access 97, mais la base est exploit� sur Office XP donc n'h�siter pas � me donner votre avis surn'importe quel version. Merci � tous, je compte sur vous. A++ Bonjour Peter, Excusez mon pauvre fran�ais qui j'ai etudie au lycee. Je ne peux pas r�pondez a votre question, mais peut-�tre je peux traduire � l'anglais... I can't answer Peter's question with any confidence, but I am going to make a valiant attempt to put my schoolboy French to use by translating his query, so that perhaps someone else can help... Regards, Lyn. --------------------------------- Hi everyone, I am developing a database dealing with job candidates. I have created some queries giving me listings of individuals according to certain criteria, and I wish to be able to proceed directly to the detail (?) information on a chosen individual (whose line is selected). The or...

php equivalent to printf("%d\n",__LINE__);
In C you can make debug statments that announce the current line number in the source, with something like: printf("%d\n",__LINE__); php (if php.ini is setup that way) often announces line numbers when catching errors. How can you do echo the equivalent of C's __LINE__ macro on non-error but interesting debugging conditions? If ($checkbook-balance < $100 && $subject == "wife") echo sys_sourceline(), "<br>"; ....or some such salmobytes wrote: > In C you can make debug statments that announce the current > line number in the source, with something like: > printf("%d\n",__LINE__); > > How can you do echo the equivalent of C's __LINE__ macro > on non-error but interesting debugging conditions? Surprise! You can do that with: <?php printf("%d\n",__LINE__); ?> Or you can use the shorter <?php echo __LINE__; ?> Cheers, -- ---------------------------------- Iv�n S�nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org- Conscience doth make cowards of us all. -- Shakespeare I forgot to mention this in my previous reply: http://php.net/manual/en/language.constants.predefined.php -- ---------------------------------- Iv�n S�nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org- Toda pulgada c�bica de espacio es un milagro.- Walt Whitman. In article <8cafc0ed-306b-405f-b9bc-94f8f7d4b116@i3g2000hsf.googlegroups.com>, salmobytes...

REGEX: can you match "w.?o.?r.?d.?" but NOT "word" ???
hope that subject made sense! :) I would like to match words that might have a character inside them; but NOT match the word if it's "whole". ie: MATCH NOT MATCH tan$gle but not tangle i-ss-ue but not issue is-su-e but not issue g-oo#d but not good tia - Bob In article <56gt60tnqkgshcs5c55v9ge7nj733fjhi0@4ax.com>, Bob <nospam_nsh@starnetwx.net> wrote: > hope that subject made sense! :) > > I would like to match words that might have a character inside them; > but NOT match the word if it's "whole". > > ie:...

I'd like to know what is diffrence between "r" and "w"... in popen()...
Hi... when I call popen ( command , mod ) , I can give "r" , "w" ,,, I'd like to know what is diffrence between "r" and "w"... man page , don't give some explain.... Thanks.. On a sunny day (Mon, 13 Aug 2007 22:47:56 +0900) it happened "google-rambo88" <rambo88@gmail.com> wrote in <f9pmtv$br0$1@news2.kornet.net>: >Hi... > when I call popen ( command , mod ) , I can give "r" , "w" ,,, > > > I'd like to know what is diffrence between "...

How to define "d/" ?
How to define "d/" ? thanks! \ : d/ ( d d -- d ) : d*u ( d u -- ud ) { uint -- ud } >r uint um* 0 r> uint * d+ ; : ud* ( ud ud -- ud ) { dl1 dh1 dl2 dh2 -- } dl1 dh1 dl2 d*u dl1 dh1 dh2 d*u drop 0 swap d+ ; : test ( -- ) 1000000000. 8 d*u d. cr 1000000000. 8. ud* d. cr ; Are you looking for something generic, or are you going for speed? On a PC, you have floating point available so : D/...

printf("....%d",sizeof((int)(double)(char) i))
Hi all, why printf("....%d",sizeof((int)(double)(char) i)) always gives the size of int ??? is it because sizeof doesn't evaluate its operand....??? aarklon@gmail.com wrote: > Hi all, > > why printf("....%d",sizeof((int)(double)(char) i)) always gives the > size of int ??? > > is it because sizeof doesn't evaluate its operand....??? It is because your code is just the longer version of printf("....%d",sizeof(int)) Bye, Jojo aarklon@gmail.com said: > Hi all, > > why printf("....%d",sizeof((int)(double)(char) ...

Web resources about - printf("%d%d%d") - comp.lang.c

Resources last updated: 3/24/2016 5:42:41 PM