I am making a program in C++ using Xcode that will generate random strings but when I do this it consumes an incredible amount of RAM. I have tried using .erase(); and .clear(); but neither seems to work.
here is my code:
void randStringMake(char *s, int l) { // AlphaNumaric characters static const char AlphaNumaric[] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "1234567890"; for(int x = 0; x < l; x++) { s[x]=AlphaNumaric[rand() % (sizeof(AlphaNumaric) - 1)]; } s[l] = 0; } char randString; randStringMake(randString, 10); std::cout << std::string(&randString) << "\n"; So i guess my question here, is how do i remove the string from the memory?