Does C++ have a UBound() or ReDim()?

Cert
09-25-2002, 10:08 PM
Just wondering..... or what comparible array functions are there in C++... if any...

usetheforce2
09-25-2002, 10:29 PM
look at New and Delete...

JDT
09-26-2002, 12:06 AM
You could use sizeof to determine the upper bounds of an array like this:

#include "stdafx.h"
#include <iostream>

int main()
{
char CharArray[586];

std::cout << sizeof(CharArray) / sizeof(char) << std::endl;

return 0;
}


You could also look int STL's vector type.

Cert
09-26-2002, 11:58 AM
doesnt SizeOf return the size of the memory it is taking? not not the number of indexes?

JDT
09-26-2002, 12:08 PM
Yes, thats why I divided it by the size of a char to get the number of elements in the array.

usetheforce2
09-26-2002, 01:11 PM
Nice trick JDT

Cert
09-26-2002, 03:01 PM
ah i see. thanks

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum