**I use Microsoft Visual Studio .NET 2003's compiler

I having trouble trying to create a 10x10 2D array. The user is supposed to give me a starting number and then it fills the array from top to bottom with ascending numbers. I am terrible at arrays and this task doesn't help me at all! If anyone would help I would gladly appreciate it!

Re: Help with a 2 Dimensional Array 80 80

I think the problem is on line 42.

Re: Help with a 2 Dimensional Array 80 80

The dynamic declination flag was accidentally switched to EIEIO. Check your atomic memory pool for floaters because they're probably causing the kernel to pop. But be careful because the memory manager is volatile and could cause the entire pipeline to dump core.

Re: Help with a 2 Dimensional Array 80 80

Unquestionably line 42, the whole 10x10 2D array is dumped onto the atomic memory pool heap! Not even one bit left!

Re: Help with a 2 Dimensional Array 80 80

Thanks for the help guys!.....?

Now, is there anyone who can help me without being a fool?

Re: Help with a 2 Dimensional Array 80 80

It's possible that they're poking at you because you didn't post any code. Please read the Announcement.

Even if this isn't a homework assignment, you're not going to get much help around here if you don't provide any code to troubleshoot.

Re: Help with a 2 Dimensional Array 80 80

>Now, is there anyone who can help me without being a fool?
Foolishness begets foolishness. Post some code and we'll help you with it. That's far more effective than asking a vague question and leaving the answer open to interpretation.

Re: Help with a 2 Dimensional Array 80 80
void twod()
{   
    int startingnum;
    int my2darray[10][10];

    cout << "\nPlease type in a starting number: ";
    cin >> startingnum;
    cout << endl << endl;

    for (int i=startingnum+100 ; startingnum < i ; startingnum++)

    cout << startingnum;
    cout << endl << endl;
}// End of twod

Sorry, I just need to know how to put startingnum in a 10x10 2D array named my2darray.

Re: Help with a 2 Dimensional Array 80 80
#include <iostream>
using namespace std;

void twod()
{
   int startingnum;
   int my2darray[10][10];

   cout << "Please type in a starting number: ";
   cin  >> startingnum;
   cout << endl << endl;

   for ( int i = 0, k = startingnum + 100; i < 10 ; ++i )
   {
      for ( int j = 0 ; j < 10 ; ++j )
      {
         my2darray[i][j] = k++;
         cout << "my2darray[" << i << "][" << j << "] = "
              << my2darray[i][j] << endl;
      }
   }
   cout << endl;
}// End of twod

int main()
{
   twod();
   return 0;
}
Re: Help with a 2 Dimensional Array 80 80

thanks for the help dave, but that wasn't what I needed. Maybe this pic of an example of a 2D array will help.

Re: Help with a 2 Dimensional Array 80 80

>but that wasn't what I needed
Maybe I'm just bitter, but don't you think it's trivial to take what Dave showed you and derive this to get what you want?

int k = 1;
for (int i = 0; i < 10; i++) {
  for (int j = 0; j < 10; j++)
    array[i][j] = k++;
}

Then you can even use the same trick to print:

#include <iomanip> // For setw

for (int i = 0; i < 10; i++) {
  for (int j = 0; j < 10; j++)
    cout<< setw(5) << aray[i][j];
  cout<<endl;
}

Or are you completely helpless? If you are then I suggest you quit right now. Helpless people don't last long as programmers.

Be a part of the DaniWeb community

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