All pastes #916568 Raw Edit

:-

public cpp v1 · immutable
#916568 ·published 2008-02-24 19:32 UTC
rendered paste body
#include <iostream>#include <fstream>using namespace std;void create_new_array(int ***array_ref, int width, int height) {	int i = 0, j = 0;	array_ref = new int **[height];	for (i = 0; i < height; i++) {		array_ref[i] = new int *[width];		for(j = 0; j < width; j++) {			array_ref[i][j] = new int [3];		}	}}int main(int n, char *params[]) {	int width = 800, height = 600, i = 0, j = 0, ascii_code_0 = int('0');	int R, G, B;	int ***array = NULL;	create_new_array(array, width, height);// 	array = new int **[height];// // 	for (i = 0; i < height; i++) {// 		array[i] = new int *[width];// 		for(j = 0; j < width; j++) {// 			array[i][j] = new int [3];// 		}// 	}	ifstream file(params[1]);	i = 0;	j = 0;	while(!file.eof() && i <= height - 1 && j <= width - 1) {		file >> R >> G >> B;		array[i][j][0] = R;		array[i][j][1] = G;		array[i][j][2] = B;		if(j == width - 1) {			j = -1;			i++;		}		j++;	}	cout << array[height - 1][width - 1][0] << endl;	for (i = 0; i < height; i++) {		for(j = 0; j < width; j++) {			delete array[i][j];		}		delete array[i];	}	delete array;	return 0;}