Reading serial data coming from arduino in c++?

PaulS:

where ard is the Serial class.

And we're supposed to guess how (and even if) you've opened the serial port, and to guess what you are currently seeing as output, and to then tell you what is wrong. I'll pass until I know more.

Sorry if you missed it, the Serial class I am referring to is in the link ( I guess i could've explained that better ). (I believe) that the Serial port is being opened in the constructor of the SerialClass object (viewable in the .cpp file through the link, I'll copy it here if you insist). In mine the only thing I changed was the baud rate (to 115200) where it sets the stopbits and parity, it was doing the same thing before, and after the change.
But due to my lack of knowledge of how c++ opens serial ports, I can't tell how to get data from the arduino. (Though as I said before, sending data to the arduino seems fine).

el_supremo:

ard.ReadData( buf, 256 );

You've told it that it can read up to 256 characters into buf, BUT

char *buf = "0";

buf points to a string containing only one character and the null on the end.

Pete

Ah, seems I need to get used to C++ a bit more (coming from java). I replaced it with:

        Serial ard = Serial("COM4");

	char *buf;
	int length = 256;
	buf = ( char* ) malloc( length );

	int num, i = 0;
	while( i < 5 ){
		num = ard.ReadData( buf, 3 );
	if( num == -1 )
	{
		cout << "\nNothing to read";
	} else
	{
		cout << "Read: ";
		for( int i = 0; i < num; i++ )
		{
			cout << *(buf + i);
		}
		cout << "Num chars: " << num;
		break;
	}
	i++;
	Sleep(500);
	}

Which seems to work now, Thanks.