print it out according to its address

For example:
1
2
3
4
5
6
7
8
9
 	
int table [3][5], x=1;
for (int i=0; i<3; i++) 
	for (int j=0; j<5; j++) 
		table[i][j] = x++; 
for (int k=0; k<15; k++) // print out 1 to 14
	cout << *((int*)table + k); // how?
// how to print out this here?
char *name[] = {"Eric", "sarah", "sam"};


Anyone help me fix it out and explain it
Thank You

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

using namespace std;

int main()
{
int table [3][5], x=1;
for (int i=0; i<3; i++) 
	for (int j=0; j<5; j++) 
		table[i][j] = x++; 
for (int k=0; k<14; k++) // print out 1 to 14
  cout << *((int*)table + k) << " "; 
}

This prints out 1 to 14.
Last edited on
Sorry, been busy these days.
Yea i know that i will print 1 to 14, but how is it store in the memory?

How to print out the {char *name[]}?
How to print out the {char *name[]}?
Like so:
1
2
3
for (int l=0; l<(sizeof(name) / sizeof(name[0])); l++)
  cout << name[l] << " "; 
}
Topic archived. No new replies allowed.