Thread: order of execution

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    164
    So you mean that (my last-most post's code) is not valid?

  2. #2
    Registered User CrissyCrisCris's Avatar
    Join Date
    Aug 2009
    Posts
    13
    Code:
    while(char c = cin.get() != 'q')
    You can hot have declare a variable in there. You are trying to declare c in there with char.

    Code:
    char c;
    while((c = cin.get()) != 'q')
    You have to declare the variable outside.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by CrissyCrisCris View Post
    Code:
    while(char c = cin.get() != 'q')
    You can hot have declare a variable in there. You are trying to declare c in there with char.
    Yes you can. That's syntactically correct code. You could have at least tried it before expounding false things.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by brewbuck View Post
    Yes you can. That's syntactically correct code. You could have at least tried it before expounding false things.
    I believe CrissyCrisCris did?
    Quote Originally Posted by CrissyCrisCris View Post
    What complier does your book tell you to use? In Microsoft Visual C++ (MSVC) you can not declare a variable inside the while's condition like that.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Order of execution of preprocessor macros
    By DL1 in forum C Programming
    Replies: 2
    Last Post: 04-02-2009, 06:52 PM
  2. order of execution of tokens in a c++ source code
    By sandy.sandipanc in forum C++ Programming
    Replies: 4
    Last Post: 10-04-2008, 12:34 PM
  3. Weird code execution order problem
    By Syko in forum C Programming
    Replies: 2
    Last Post: 05-12-2005, 02:29 PM
  4. expression execution order
    By _Elixia_ in forum C Programming
    Replies: 3
    Last Post: 10-02-2003, 04:01 PM
  5. randomizing order of execution of function
    By y2jasontario in forum C Programming
    Replies: 2
    Last Post: 04-03-2002, 07:50 PM