legal validation construct?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Geekibz
    New Member
    • Jan 2008
    • 12

    #1

    legal validation construct?

    [code=c]int d;
    scanf("%d",&r);
    r=getchar();[/code] Is this a legal validation construct?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Assuming you meant int r; and not int d; then yes that is valid. However the scanf line serves little purpose as the value of r is overwritten by the getchar line.

    Also note that it is very easy in C/C++ to write code that is completely legal while at the same time being logically undesirable.

    Comment

    Working...