Xcode 3.1.1 issue - Debugger Console losing data

Discussion in 'Mac Programming' started by toddburch, Dec 4, 2008.

  1. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #1
    I have a C++ command line app, and when debugging it in Xcode, my cin.getline(char_array, some_byte_count) fails by looking like it took the input (the cin is no longer blocking), and cin.good() is set, but when I look at the debugger console, the char_array is un-initialized.

    At first my project setting was 3.1.1 and that was REALLY screwing up by missing my break points. I started a new, clean project, copy/pasted all my code over (not that much) and went into Project Settings and picked Xcode 3.0. It worked a few times properly (the cin.getline() worked), but now it's not working. I've quit (completely) Xcode a few times, and each time now I get the same incorrect behavior.

    Here's some sample code that fails: (pretty trivial stuff)
    Code:
    #include <iostream>
    
    using namespace std ; 
    
    int main (int argc, char * const argv[]) {
        int count ; 
    	char filename[255] ; 
    	count = 0 ; 
    	cout << "Enter a file name" << endl ; 
    	[color=red]cin.getline(filename, 255) ; [/color]
    	if ( !cin.good() ) { 
    		cout << "Error reading cin." << endl ; 
    		return -1 ; 
    	}
    	cout << "File name is >" << filename << "<." << endl ; 
    	return 0;
    }
    
    When you step thru it and get to the cin.getline(), press sihft+cmd+R to open the console, and then PASTE in a path, like /Users/me/Desktop/my.txt and see if you get the same problem.

    It seems when I type data, all is OK, but when I paste data, that's when it fails.
     
  2. SydneyDev macrumors 6502

    Joined:
    Sep 15, 2008
    #2
    3.1.2 has been available for a few weeks now ... maybe that fixes it.
     

Share This Page