I need a help with c++.
int *tab1[5];
int tab2[] = {3, 4, 5};
tab1[0] = tab2;
It works but I want to have a variable instead of 5 in first line. Any ideas? Thanks you in advance.
I need a help with c++.
int *tab1[5];
int tab2[] = {3, 4, 5};
tab1[0] = tab2;
It works but I want to have a variable instead of 5 in first line. Any ideas? Thanks you in advance.
 
    
    Since you found the "wrong" answer I'll show you the "correct":
#include <iostream>
#include <vector>
int main()
{
    std::cout << "How many lines do you want? ";
    unsigned lines;
    if (!(std::cin >> lines))
    {
        std::cout << "Invalid input\n";
        return 1;
    }
    std::vector<std::vector<int>> tab(lines);
    if (lines > 0)
    {
        tab[0] = { 3, 4, 5 };
    }
}
 
    
    I found an answer,
int n = 5;
int **tab1 = new int*[n];
int tab2[] = {3, 4, 5};
tab1[0] = tab2;
Thanks for your attention.
