mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-11 14:36:25 +08:00
error in line 23 i.e a constant value
in line 23. int a[n]; give error while running i.e. expression must have a constant value. so, rectifying this we can use pointer. int* a = new int[n];
This commit is contained in:
@@ -20,7 +20,13 @@ int main(int argc, char const *argv[])
|
||||
cout << "Enter size of array: ";
|
||||
cin >> n;
|
||||
cout << "Enter array elements: ";
|
||||
/*
|
||||
int a[n];
|
||||
getting error size must be declare
|
||||
so for rectifying this use pointer.
|
||||
int a[n]; replace by int* a = new int[n];
|
||||
*/
|
||||
int* a = new int[n];
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
cin >> a[i];
|
||||
@@ -33,4 +39,4 @@ int main(int argc, char const *argv[])
|
||||
else
|
||||
cout << key << " not found" << endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user