Namespace error!

Hello every one! Nice to meeting you on this forum. I am new here also in C++. I have the following question-

Why the following code showing "namespace name expected" error? What should I do to remove this error?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;
int main()
{
cout << "\nSize of Fundamental Types\n"<< "Number of Bytes\n"<< "-----" << endl;
cout << " char: " << sizeof(char) << endl;
cout << " short: " << sizeof(short)<< endl;
cout << " int: " << sizeof(int) << endl;
cout << " long: " << sizeof(long) << endl;
cout << " float: " << sizeof(float)<< endl;
cout << " double: " << sizeof(double)<<endl;
cout << " long double: " << sizeof(long double)<< endl;
return 0;
}
Last edited on
Hi. It compiles OK on MS with VS2019.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;

int main()
{
	cout << "\nSize of Fundamental Types\n" << "Number of Bytes\n" << "-----" << endl;
	cout << " char: " << sizeof(char) << endl;
	cout << " short: " << sizeof(short) << endl;
	cout << " int: " << sizeof(int) << endl;
	cout << " long: " << sizeof(long) << endl;
	cout << " float: " << sizeof(float) << endl;
	cout << " double: " << sizeof(double) << endl;
	cout << " long double: " << sizeof(long double) << endl;
	return 0;
}



Size of Fundamental Types
Number of Bytes
-----
 char: 1
 short: 2
 int: 4
 long: 4
 float: 4
 double: 8
 long double: 8

closed account (z05DSL3A)
PK Dey, What compiler are you using?
But In Borland C++ compiler The error is displaying! Is there any problem with Borland C++ compiler?
Most likely, what is the exact version of that outdated compiler?

You really should get a newer compiler, there are several available that are free to download.

Thank! I am going to change my compiler
Someone took it over as a project but nothing from borland is newer than 2005, and most of it is from the 1990s or even earlier. You should use something else. If you like borland builder, there is an opensource project or something that continues it?
Topic archived. No new replies allowed.