Thread: alternative to cin

  1. #16
    S­énior Member
    Join Date
    Jan 2002
    >When did I ever mention anything but the basic loop I made?<

    Sorry I had no idea why you posted the asm. I assumed it was an attempt to justify your desicion not to turn on your compilers optimser. Which seemed like a likely shot in the dark considering you mentioned compiler optimisation.

    >All that I was trying to show is that in unoptimized code, my use of the infamous goto would be more effecient.<

    How does this show that? Have you even looked at the diassembly of the method I described that doesn't use the infamous goto. Efficiency is not an excuse for using goto in this case. Since you seem to be having a hard time -


    is the same as


    which compiles in a debug build to -

    cmp DWORD PTR _i$[ebp], 0
    jge SHORT $L9394
    jmp SHORT $L9393

    No compiler optimisation. No use of the infamous goto. 3 instructions.

  2. #17
    Registered User
    Join Date
    Oct 2001
    I have to admit, in golfinguy's example, I don't see how the goto would be more efficient than the while loop. Both test to see whether to end the loop. Maybe I'm missing something.

  3. #18
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Because a while loop has to test the value of its argument. Since one is always considered to be true, it continues on with what is inside the loop. However, my use of goto's eliminates the need to test the value of the argument.

    P.S. Sorensen, I do use my compiler optimizer. I said that I know others that don't use it.

  4. #19
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Also Sorensen, you did use an optimizer when you rewrote the loop. It was your brain, which is not a machine, but you still performed optimization.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cin problem
    By mikahell in forum C++ Programming
    Replies: 12
    Last Post: 08-22-2006, 11:14 AM
  2. getline(function)??
    By dac in forum C++ Programming
    Replies: 7
    Last Post: 03-10-2006, 12:42 PM
  3. cin not allowing input after first use of function
    By Peter5897 in forum C++ Programming
    Replies: 5
    Last Post: 01-31-2006, 06:29 PM
  4. Overriding Cin with Cout
    By Tainted in forum C++ Programming
    Replies: 5
    Last Post: 10-06-2005, 02:57 PM
  5. Simple Question relating to the IOStream Lib and Cin
    By XcomvB in forum C++ Programming
    Replies: 6
    Last Post: 06-12-2003, 02:17 AM