Hello! I would like to ask if its possible to change the size of the array? For example, the user will input a characters then that characters will be counted and the size of the array will be change. For example of the output:
Enter your name: Laklaker
The size of the array is: 8.

Recommended Answers

All 2 Replies

Why use an array? Since you're just asking for the persons namr, you can do:

#include <string>
#include <iostream>
int main() {

    std::string name; 

    std::cout << "Please enter your name: ";
    std::cin >> name;

    std::cout << "Size: " << name.length();
}

I would like to ask if its possible to change the size of the array

No, arrays are given a size at compile time and that cannot be changed at runtime. There are ways of simulating an array that can be resized, but those methods are already incorporated into standard classes such as vector or string. You should prefer those libraries to rolling your own ad hoc code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.