Hi,
I've been trying to compile the following code in visual c++ 2010 Express Edition.

But the output window just says:
1>------ Build started: Project: Ans7, Configuration: Debug Win32 ------
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Code Follows:

/*Program to dynamically allocate a 2D array*/
#include<iostream.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
using namespace std;
void printmat(int **p,int m,int n)
{
	int i,j;
	//Print Full Matrix:
	cout<<"The full Matrix is:\n";
	for(i=0;i<m;i++)
	{
		cout<<"\n";
		for(j=0;j<n;j++)
			cout<<p[i][j]<<"  ";
	}

	//print the lower matrix:
	cout<<"The Lower Triangle is\n";
	for(i=0;i<m;i++)
	{
		cout<<endl;
		for(int j=0;j<n;j++)
		{
			if(i<j)
				break;
			else
				cout<<p[i][j]<<"  ";
		}
	}
}

void main()
{       //clrscr();
	int **p,m,n,i,j;
	cout<<"Enter the no of Rows:  ";
	cin>>m;
	cout<<"Enter the no of Columns:  ";
	cin>>n;
	//Dynamic allocation of 2D array:
	p=new int*[m];
	for(i=0;i<m;i++)
		p[i]=new int[n];
	//Taking I\P:
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			printf("Enter p[%d][%d]:  ",i,j);
			scanf("%d",&p[i][j]);
		}
	}
	printmat(p,m,n);
	getch();
}

But the output window just says:
1>------ Build started: Project: Ans7, Configuration: Debug Win32 ------
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

A compiler wouldn't "just say" that, especially not the MS Visual Studio compiler. There must be some errors that it's reporting, please share them.

The first thing I can see that you need to do is get your code up to date:
The statements #include <iostream.h> and #include <iostream> do not mean the same thing.

The first version is a pre-standard C++ header. The std namespace (which you are trying to use) does not exist in it, it should only be used for legacy code that isn't being modernized. The second version is an ANSI/ISO Standard C++ header, this is the one you should be using for any new/modern code.

The same applies for <stdlib.h> and <stdio.h>. They are old versions of the C headers of the same names. In modern code, you should replace them with <cstdlib> and <cstdio> respectively.

Oh, and don't use "conio.h" it's not standardized and code that uses it isn't portable.

Hi Fbody,

I tried out your suggestions...
It worked when I replaced <iostream.h> with <iostream> and left the others as they were, but not when i changed all of them.

then I tried to compile it again, and it's still syaing the same thing.

The Output Window contents are:

1>------ Build started: Project: Ans7, Configuration: Debug Win32 ------
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

It gives no reason why the program fails to compile!!

I'm using VC++ 2010 Express Edition.
Is it a problem with the compiler?

Oh and a dialog box pops up saying that there were build errors and would i like to run the last successful build?

1>------ Build started: Project: test1, Configuration: Debug Win32 ------
1> test1.cpp
1>c:\dvlp\unmanaged\test1\test1.cpp(2): fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Notice the second line tells you what's wrong. Then if you removed the .h file extension your compiler should have given you these messages

1>------ Build started: Project: test1, Configuration: Debug Win32 ------
1>  test1.cpp
1>c:\dvlp\unmanaged\test1\test1.cpp(51): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'
1>c:\dvlp\unmanaged\test1\test1.cpp(55): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\conio.h(128) : see declaration of 'getch'
1>  LINK : c:\dvlp\unmanaged\Debug\test1.exe not found or not built by the last incremental link; performing full link
1>  test1.vcxproj -> c:\dvlp\unmanaged\Debug\test1.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Hey Guys

Thanks for your help!!!

The problem's gone now!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.