0
If there any way to make x = 2 when i call the second f(arr)
#include<iostream> using namespace std; void f(int arr[]) { int x = 0; cout << arr[x]; x++; } int main() { int arr[4] = { 1, 2, 3, 4 }; f(arr); f(arr); }
7 ответов
+ 5
Yes, just add the keyword "static"
static int x = 0;
+ 1
Thank you man
You are amazing👍
0
Thanks
0
I can make it global too