Hey guys, what i'm basically trying to do in this
code is to write an array which is automatically written to a txt file in the order I have shown below, however, I not only get this error

--------------------Configuration: testmtl - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/testmtl.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

testmtl.exe - 2 error(s), 0 warning(s)

But I also can not get any output on the file, I can sometimes get it to cout the values which are correct but can not get it to output to a text file, please help me to fix this!!!

Kind regards,
Zane.

#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;

int main()
{
	int ne = 10; //change
	int nn;
	int j = 1;
	int k = 1;
	int i = 1;
	ofstream out;
	out.open("input_matlab_array.txt");
	nn = ne + 1;
	int array1[11]; //change
	int array2[11]; //change
	int array3[11]; //change (number of nodes per line)


	while (i <= nn)
	{

		array1[i]= k;
		k++;
		i++;
	};


	i = 1;

	while (i <= nn)
	{

		array2[i]= k;
		k++;
		i++;
	};

	i = 1;

	while (i <= nn)
	{

		array3[i]= k;
		k++;
		i++;
	};


	i = 1;
		while (i <= ne)
	{
		out << i << "     " << array1[i] << " " << array2[i] << " " << array2[i+1] << " " << array1[i+1] << endl;
		i++;
	};
	i = 1;

	while (i <= ne)
	{
		out << i << "     " << array2[i] << " " << array3[i] << " " << array3[i+1] << " " << array2[i+1] << endl;
		i++;
	};
	out.close();
	return 0;
};

Interesting. I was able to compile and run the program correctly under GCC, which leads me to think that the problem is with your project file rather than the code itself. I may be wrong, however...

Apologies, what is GCC?

Edit: Just saw what GCC is, how would I compile it correctly in there, sorry for the trouble

While my point had more to do with there being a problem with your VC++ setup rather than a suggestion to switch compilers, you might find it worth learning about GCC as an alternative approach (and it is often useful to have two different compilers to use for comparison tests). You can get the MinGW port of GCC for Windows, which gives you the command-line compiler and toolset. Conversely, you could get the Code::Blocks IDE, which comes bundled with MinGW and is a lot easier to get started with (make sure you get the version marked 'mingw-setup'). I would recommend eventually learning to use the command-line tools, as it clarifies a lot about how compilers really work, but if you're just starting out, using an IDE is a lot easier.

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.