User creating an array

I want a user to be able to define how many elements in an array and then fill it in
Current code to make an example of what i want to know how to do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "stdafx.h"
#include <stdio.h>
int int1;



int main()
{
	printf("How many words?");
	scanf_s(int1);
	char * array1[int1];
	


	return 0;
}
Given that this is a C++ forum:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>
#include <vector>

int main() {
    unsigned sz;
    std::cout << "How many words? ";
    std::cin >> sz;

    std::vector<std::string> words(sz);

    for (auto& word: words) std::cin >> word;

    std::cout << "You entered:\n";
    for (auto& word: words) std::cout << "> " << word << '\n';
}
Topic archived. No new replies allowed.