Silly question

Hello, Im new to C++ and I am having some issues with arrays of chars (strings I belive). My issue is that I dont know how to get how many elements of the array are in use, this is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Texture:public Decleration {
public:
	Texture(char paramFilePath[512]):
	  objectType(2) {
		DwarfstarObject::TickObjectCount(true);
		for(i = 0; i < 255; i ++) {
			filePath[i] = paramFilePath[i];
		}
	}
	~Texture() {
		objectType(-1)
		DwarfstarObject::TickObjectCount(false);
	}
}
Now what will end up happening is that filePath will have lots of unused and unneeded elements that are wasting memory and what I want to do is get how many are actually being used to I can make a new array with that amount of elements and fill it up and save memeory
-Thanks
Why not just use std::string like everyone else? It does the abstraction from size for you.
if you put a NULL char after your pathname, you can just do a 'for' loop and check (if path[i]==NULL) save=i;
then save will have the length of your path name (including the NULL ('\0') character)
Topic archived. No new replies allowed.