[Dev-C++] MinGW 2.95 vs Borland 5.5 compiler
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Luigi S. <gi...@li...> - 2002-01-04 19:07:22
|
Hello,
I have both MinGW 2.95 and the Borland 5.5 compiler here are a couple of
things that
the two compilers manage differently: since my knowledge of the ANSI C++ is
very limited, I welcome any hints about which one complies with the ANSI
standard.
1) I needed to include the C standard header file "ctype.h" into a C++
source file;
should I use:"#include <cctype>" (as MinGW says) or "#include <ctype>" (as
Borland 5.5 says)?
Of course I can always use "#include <ctype.h>", but I suspect that this is
"old" C++.
2) I need to read a C++ string and the character that comes just after the
string;
should I assume that: spaces after the string are left on the stream (as
MinGW says)
or that spaces after the string are extracted and discarded (as Borland 5.5
says)?
The following code is the one that I used to track the different behaviors:
simple.c
---------
#include <iostream>
#include <string>
//////////////////////////////////////////////////////////////////////
int
main()
{
std::string s;
std::cin >> s;
std::cout << "\nThe string found on the stream is:\t\"" << s
<< "\"\nthe character that follows it is a:\t";
switch(int c = std::cin.peek())
{
default:
std::cout << '\'' << (char) c << "\'\n";
break;
case EOF:
std::cout << "EOF\n";
break;
case '\n':
std::cout << "newline\n";
break;
case '\t':
std::cout << "tab\n";
break;
case ' ':
std::cout << "space\n";
break;
}
}
---------
Of course if my code is wrong, please let me know it.
Thanks for your time
--
gisan
|