Thread: Compiler Question

  1. #1
    Join Date
    Nov 2002

    Compiler Question

    I have a question its more of a curiosity thing really. When I compile the code below and make an exe the program works differently depending on the compiler I use. Yet the code is exactly the same. Anyone know why?

    #include <iostream>
    #include <string>
    using namespace std;
    int main() {
    	string y;
    	cout << y;
    	return 0;
    When I compile that with VC++, it prompts me to enter a value. After I type whatever in and press enter, I have to press Enter once again for the cout statement to work.

    But when compiled in Dev C++ , it works properly and the cout statement executes as soon as I hit enter. Any idea why they work differently if its the same exact code?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    VC++ has a bug in getline that requires you to hit return twice.

    My best code is written with the delete key.

  3. #3
    Join Date
    Nov 2002
    Thank You !! It was driving me nuts wondering hehe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about compiler copying objects
    By Sharke in forum C++ Programming
    Replies: 3
    Last Post: 06-15-2009, 08:25 AM
  2. gcc compiler question
    By s_ny33 in forum C Programming
    Replies: 6
    Last Post: 10-18-2005, 07:13 AM
  3. question about bool
    By ssharish2005 in forum C Programming
    Replies: 7
    Last Post: 10-17-2005, 08:18 AM
  4. C/C++ Compiler Question
    By Unregistered in forum C++ Programming
    Replies: 11
    Last Post: 07-09-2002, 02:09 AM
  5. Question: Which Compiler????
    By MaBo in forum C Programming
    Replies: 5
    Last Post: 06-04-2002, 11:57 AM