Namespace error!

Dec 28, 2020 at 3:22pm
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 Dec 28, 2020 at 3:23pm
Dec 28, 2020 at 3:27pm
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

Dec 28, 2020 at 3:30pm
Dec 28, 2020 at 3:32pm
closed account (z05DSL3A)
PK Dey, What compiler are you using?
Dec 28, 2020 at 3:37pm
But In Borland C++ compiler The error is displaying! Is there any problem with Borland C++ compiler?
Dec 28, 2020 at 3:41pm
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.

Dec 28, 2020 at 3:44pm
Thank! I am going to change my compiler
Dec 28, 2020 at 3:52pm
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.