Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3021

How to initialize an array whose size is initially unknown

$
0
0
Hello all ,

Note: These values[xup -yup -xright - etc ..] are constantly changing
My example ..

Code:

#include <iostream>



int main() {

int xup = 721 ;
int yup = 575;
int xright = 726;
int yright = 570;
int xleftdown = 731;
int yleftdown = 586;
int xlenth = xright - xup;
int ylenth = yup - yright;
int hight = xleftdown - xup ;

std::cout << "xlenth " << xlenth << " ylenth " << ylenth << " hight " << hight<< "\n";

int x,y,x1,y1;
for (int i = 1; i <= xlenth; ++i) {
x = xup + i;
y = yup -i;

std::cout << x << "," << y << "\n";


for (int j = 1; j <= hight; ++j) {

x1 = x + j;
y1 = y + j;
int add = y1+ 1;
std::cout << x1 << "," << y1 << "\n";
std::cout << x1 << "," << add << "\n";
}

}
return 0;
}

output :
722,574
723,575
723,576
724,576
etc ...

Another question, is it possible to add (Not + )variables next to each other?
like this :
int x = 5;
int y = 6;
int sum;
sum = x&y; // I know it's wrong but I want something like this
output:
56

Then I will add output to array .. Thanks

Viewing all articles
Browse latest Browse all 3021

Trending Articles